[build] cmd/resultdbpprof: add tool to get a test execution profile

0 views
Skip to first unread message

Gopher Robot (Gerrit)

unread,
Dec 15, 2025, 11:31:51 PM (11 hours ago) Dec 15
to Michael Knyszek, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Go LUCI, Dmitri Shuralyov, Dmitri Shuralyov, golang-co...@googlegroups.com

Gopher Robot submitted the change with unreviewed changes

Unreviewed changes

2 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:

```
The name of the file: cmd/resultdbpprof/main.go
Insertions: 26, Deletions: 4.

@@ -42,14 +42,13 @@
"time"

"github.com/google/pprof/profile"
- "golang.org/x/sync/errgroup"
- "google.golang.org/protobuf/types/known/fieldmaskpb"
-
"go.chromium.org/luci/auth"
bbpb "go.chromium.org/luci/buildbucket/proto"
"go.chromium.org/luci/grpc/prpc"
"go.chromium.org/luci/hardcoded/chromeinfra"
rdbpb "go.chromium.org/luci/resultdb/proto/v1"
+ "golang.org/x/sync/errgroup"
+ "google.golang.org/protobuf/types/known/fieldmaskpb"
)

var (
@@ -57,6 +56,24 @@
public = flag.Bool("public", true, "whether the build is public or not")
)

+func init() {
+ flag.Usage = func() {
+ fmt.Fprintf(flag.CommandLine.Output(), "Usage: %s [flags] <build ID>\n", os.Args[0])
+ fmt.Fprintf(flag.CommandLine.Output(), "\n")
+ fmt.Fprintf(flag.CommandLine.Output(), "Downloads test results for a LUCI build and generates a pprof\n")
+ fmt.Fprintf(flag.CommandLine.Output(), "profile of their execution times. Useful for understanding test\n")
+ fmt.Fprintf(flag.CommandLine.Output(), "execution times and identifying low hanging fruit to speed up CI.\n")
+ fmt.Fprintf(flag.CommandLine.Output(), "Results are written to '<build ID>.prof' in the current working\n")
+ fmt.Fprintf(flag.CommandLine.Output(), "directory.\n")
+ fmt.Fprintf(flag.CommandLine.Output(), "\n")
+ fmt.Fprintf(flag.CommandLine.Output(), "This tool expects Go test names of the form 'pkg.TestX/Y/Z'.\n")
+ fmt.Fprintf(flag.CommandLine.Output(), "Test names not matching this pattern may appear in the output in\n")
+ fmt.Fprintf(flag.CommandLine.Output(), "an unexpected form.\n")
+ fmt.Fprintf(flag.CommandLine.Output(), "\n")
+ flag.PrintDefaults()
+ }
+}
+
func main() {
// Validate flags.
flag.Parse()
@@ -67,7 +84,12 @@
flag.Usage()
os.Exit(1)
}
- buildID, err := strconv.ParseInt(flag.Arg(0), 10, 64)
+ idArg := flag.Arg(0)
+ idArg, _ = strings.CutPrefix(idArg, "b") // Allow optional 'b' prefix for easier copy-pasting.
+ buildID, err := strconv.ParseInt(idArg, 10, 64)
+ if err != nil {
+ log.Fatalf("parsing build ID %s: %v", flag.Arg(0), err)
+ }

// Create client.
ctx := context.Background()
```

Change information

Commit message:
cmd/resultdbpprof: add tool to get a test execution profile
Change-Id: Ia5e0a9265fab5b0f8ee3c5aca00c43df18cac6fe
Reviewed-by: Dmitri Shuralyov <dmit...@golang.org>
Reviewed-by: Dmitri Shuralyov <dmit...@google.com>
Auto-Submit: Michael Knyszek <mkny...@google.com>
Files:
  • A cmd/resultdbpprof/main.go
  • M go.mod
  • M go.sum
Change size: L
Delta: 3 files changed, 310 insertions(+), 1 deletion(-)
Branch: refs/heads/master
Submit Requirements:
  • requirement satisfiedCode-Review: +1 by Dmitri Shuralyov, +2 by Dmitri Shuralyov
  • requirement satisfiedTryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: build
Gerrit-Branch: master
Gerrit-Change-Id: Ia5e0a9265fab5b0f8ee3c5aca00c43df18cac6fe
Gerrit-Change-Number: 730168
Gerrit-PatchSet: 4
Gerrit-Owner: Michael Knyszek <mkny...@google.com>
Gerrit-Reviewer: Dmitri Shuralyov <dmit...@golang.org>
Gerrit-Reviewer: Dmitri Shuralyov <dmit...@google.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Michael Knyszek <mkny...@google.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages