Skip to content

Commit

Permalink
sweet: fix redundant runs in pgo benchmarks
Browse files Browse the repository at this point in the history
This CL fix a bug that duplicates benchmark runs for every configs if
it's under pgo settings. The unnecessary codes are removed.

Change-Id: Ic03294034ace4534802eefa96cc113646d8ed159
Reviewed-on: https://go-review.googlesource.com/c/benchmarks/+/621535
Reviewed-by: Michael Pratt <[email protected]>
Reviewed-by: Junyang Shao <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Auto-Submit: Junyang Shao <[email protected]>
  • Loading branch information
JunyangShao authored and gopherbot committed Oct 21, 2024
1 parent 91d9ffc commit 5a70838
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions sweet/cmd/sweet/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,31 +427,33 @@ func (c *runCmd) preparePGO(configs []*common.Config, benchmarks []*benchmark) (

// Merge all the profiles and add new PGO configs.
newConfigs := configs
var successfullyMergedBenchmarks []*benchmark
for i := range configs {
origConfig := configs[i]
profileConfig := profileConfigs[i]
pgoConfig := origConfig.Copy()
pgoConfig.Name += ".pgo"
pgoConfig.PGOFiles = make(map[string]string)
noMergeError := true

for _, b := range successfullyExecutedBenchmarks {
p, err := mergeCPUProfiles(profileRunCfg.runProfilesDir(b, profileConfig))
if err != nil {
log.Error(fmt.Errorf("error merging profiles for %s/%s: %w", b.name, profileConfig.Name, err))
noMergeError = false
} else {
successfullyMergedBenchmarks = append(successfullyMergedBenchmarks, b)
pgoConfig.PGOFiles[b.name] = p
}
}

newConfigs = append(newConfigs, pgoConfig)
if noMergeError {
newConfigs = append(newConfigs, pgoConfig)
}
}
if len(successfullyExecutedBenchmarks) == 0 {
return nil, nil, fmt.Errorf("failed to merge profiles for any benchmarks, see logs for more details")
}

return newConfigs, successfullyMergedBenchmarks, nil
return newConfigs, successfullyExecutedBenchmarks, nil
}

var cpuProfileRe = regexp.MustCompile(`-cpu\.prof$`)
Expand Down

0 comments on commit 5a70838

Please sign in to comment.