sweet/benchmarks/go-build: commit perf diagnostics before general commit Before this CL, because of the order the defers would run in, we'd first do the commit on the overall diagnostics object before doing the commit of the perf diagnostics. This would result in the overall commit (which expects the perf diagnostics to already be there) to try to collect the committed perf diagnostics file (which hasn't been committed yet, so doesn't exist at the expected location) and then delete all the individual diagnostics files including the temp file. Then when we try to commit the perf diagnostics, the temp file doesn't exist anymore, so that operation fails. Make sure to commit the perf diagnostics before committing the combined diagnostics. Change-Id: Id018e8162891a662e8bad18f7289da31c36e83c1 Reviewed-on: https://go-review.googlesource.com/c/benchmarks/+/689495 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Michael Knyszek <mknyszek@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Michael Matloob <matloob@google.com>
diff --git a/sweet/benchmarks/go-build/main.go b/sweet/benchmarks/go-build/main.go index 3edc700..c3c9a80 100644 --- a/sweet/benchmarks/go-build/main.go +++ b/sweet/benchmarks/go-build/main.go
@@ -89,11 +89,11 @@ cmdArgs = append(cmdArgs, "-toolexec", strings.Join(selfCmd, " ")) - if df, err := diag.Create(diagnostics.Perf); err != nil { + df, err := diag.Create(diagnostics.Perf) + if err != nil { fmt.Fprintf(os.Stderr, "failed to create %s diagnostics: %s\n", diagnostics.Perf, err) } else if df != nil { df.Close() - defer df.Commit() perfArgs := []string{"perf", "record", "-o", df.Name()} perfArgs = append(perfArgs, driver.PerfFlags()...) @@ -112,6 +112,9 @@ } err = driver.RunBenchmark(name, func(d *driver.B) error { defer diag.Commit(d) + if df != nil { + defer df.Commit() + } return cmd.Run() }, append(benchOpts, driver.DoAvgRSS(cmd.RSSFunc()))...) if err != nil {