Skip to content

Commit b309d4e

Browse files
committed
cmd/coordinator: hard-code the tools baseline commit for benchmarks
For the short term, we want to compare with v0.11.0. Hard code a commit that includes additional instrumentation. Add a TODO to select the latest patch release of the prior minor version. Updates golang/go#60926 Change-Id: If00a5a5f75d7a06af877dfdf2d78635a7ef3bd49 Reviewed-on: https://go-review.googlesource.com/c/build/+/509895 Run-TryBot: Robert Findley <rfindley@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
1 parent 16005bf commit b309d4e

File tree

1 file changed

+35
-12
lines changed

1 file changed

+35
-12
lines changed

cmd/coordinator/buildstatus.go

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -809,47 +809,70 @@ func (st *buildStatus) toolchainBaselineCommit() (baseline string, err error) {
809809
return "", fmt.Errorf("cannot find latest release for %s", st.RevBranch)
810810
}
811811

812+
// Temporarily hard-code the subrepo baseline commits to use.
813+
//
814+
// TODO(rfindley): in the future, we should use the latestRelease method to
815+
// automatically choose the latest patch release of the previous minor version
816+
// (e.g. v0.11.x while we're working on v0.12.y).
817+
var subrepoBaselines = map[string]string{
818+
"tools": "6ce74ceaddcc4ff081d22ae134f4264a667d394f", // gopls@v0.11.0, with additional instrumentation for memory and CPU usage
819+
}
820+
812821
// subrepoBaselineCommit determines the baseline commit for this subrepo benchmark run.
813822
func (st *buildStatus) subrepoBaselineCommit() (baseline string, err error) {
814-
if st.SubName != "tools" {
823+
commit, ok := subrepoBaselines[st.SubName]
824+
if !ok {
815825
return "", fmt.Errorf("unknown subrepo for benchmarking %q", st.SubName)
816826
}
827+
return commit, nil
828+
}
817829

830+
// latestRelease returns the latest release version for a module in subrepo. If
831+
// submodule is non-empty, it is the path to a subdirectory containing the
832+
// submodule of interest (for example submodule is "gopls" if we are
833+
// considering the module golang.org/x/tools/gopls). Otherwise the module is
834+
// assumed to be at repo root.
835+
//
836+
// It is currently unused, but preserved for future use by the
837+
// subrepoBaselineCommit method.
838+
func (st *buildStatus) latestRelease(submodule string) (string, error) {
818839
// Baseline is the latest gopls release tag (but not prerelease).
819840
gerritClient := pool.NewGCEConfiguration().GerritClient()
820841
tags, err := gerritClient.GetProjectTags(st.ctx, st.SubName)
821842
if err != nil {
822843
return "", fmt.Errorf("error fetching tags for %q: %w", st.SubName, err)
823844
}
824845

825-
goplsVersions := make([]string, 0)
826-
goplsRevisions := make(map[string]string)
846+
var versions []string
847+
revisions := make(map[string]string)
848+
prefix := "refs/tags"
849+
if submodule != "" {
850+
prefix += "/" + submodule // e.g. gopls tags are "gopls/vX.Y.Z"
851+
}
827852
for ref, ti := range tags {
828-
// gopls tags are "gopls/vX.Y.Z". Ignore non-gopls tags.
829-
const prefix = "refs/tags/gopls/"
830853
if !strings.HasPrefix(ref, prefix) {
831854
continue
832855
}
833856
version := ref[len(prefix):]
834-
goplsVersions = append(goplsVersions, version)
835-
goplsRevisions[version] = ti.Revision
857+
versions = append(versions, version)
858+
revisions[version] = ti.Revision
836859
}
837860

838-
semver.Sort(goplsVersions)
861+
semver.Sort(versions)
839862

840863
// Return latest non-prerelease version.
841-
for i := len(goplsVersions) - 1; i >= 0; i-- {
842-
ver := goplsVersions[i]
864+
for i := len(versions) - 1; i >= 0; i-- {
865+
ver := versions[i]
843866
if !semver.IsValid(ver) {
844867
continue
845868
}
846869
if semver.Prerelease(ver) != "" {
847870
continue
848871
}
849-
return goplsRevisions[ver], nil
872+
return revisions[ver], nil
850873
}
851874

852-
return "", fmt.Errorf("no valid versions found in %+v", goplsVersions)
875+
return "", fmt.Errorf("no valid versions found in %+v", versions)
853876
}
854877

855878
// reportErr reports an error to Stackdriver.

0 commit comments

Comments
 (0)