@@ -809,47 +809,70 @@ func (st *buildStatus) toolchainBaselineCommit() (baseline string, err error) {
809
809
return "" , fmt .Errorf ("cannot find latest release for %s" , st .RevBranch )
810
810
}
811
811
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
+
812
821
// subrepoBaselineCommit determines the baseline commit for this subrepo benchmark run.
813
822
func (st * buildStatus ) subrepoBaselineCommit () (baseline string , err error ) {
814
- if st .SubName != "tools" {
823
+ commit , ok := subrepoBaselines [st .SubName ]
824
+ if ! ok {
815
825
return "" , fmt .Errorf ("unknown subrepo for benchmarking %q" , st .SubName )
816
826
}
827
+ return commit , nil
828
+ }
817
829
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 ) {
818
839
// Baseline is the latest gopls release tag (but not prerelease).
819
840
gerritClient := pool .NewGCEConfiguration ().GerritClient ()
820
841
tags , err := gerritClient .GetProjectTags (st .ctx , st .SubName )
821
842
if err != nil {
822
843
return "" , fmt .Errorf ("error fetching tags for %q: %w" , st .SubName , err )
823
844
}
824
845
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
+ }
827
852
for ref , ti := range tags {
828
- // gopls tags are "gopls/vX.Y.Z". Ignore non-gopls tags.
829
- const prefix = "refs/tags/gopls/"
830
853
if ! strings .HasPrefix (ref , prefix ) {
831
854
continue
832
855
}
833
856
version := ref [len (prefix ):]
834
- goplsVersions = append (goplsVersions , version )
835
- goplsRevisions [version ] = ti .Revision
857
+ versions = append (versions , version )
858
+ revisions [version ] = ti .Revision
836
859
}
837
860
838
- semver .Sort (goplsVersions )
861
+ semver .Sort (versions )
839
862
840
863
// 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 ]
843
866
if ! semver .IsValid (ver ) {
844
867
continue
845
868
}
846
869
if semver .Prerelease (ver ) != "" {
847
870
continue
848
871
}
849
- return goplsRevisions [ver ], nil
872
+ return revisions [ver ], nil
850
873
}
851
874
852
- return "" , fmt .Errorf ("no valid versions found in %+v" , goplsVersions )
875
+ return "" , fmt .Errorf ("no valid versions found in %+v" , versions )
853
876
}
854
877
855
878
// reportErr reports an error to Stackdriver.
0 commit comments