Skip to content

Commit d1037ce

Browse files
committed
cmd/coordinator: attempt to run newer work before older work on buildlets
The problem is especially severe on the slow builders, like darwin/arm64, which can sometimes not have run any commit from the past 12 hours and still pick an old commit for its next trial. It would be far better for it to prefer new work. It's possible that this new logic should be disabled for some of the auto-scaling builders, but for now it seems like we can try it for all of them and see if that's OK. Update golang/go#19178. Change-Id: I32cc67c0c2c84130b40b250675b40aadb4a0a681 Reviewed-on: https://go-review.googlesource.com/70430 Run-TryBot: Russ Cox <[email protected]> Reviewed-by: Sarah Adams <[email protected]>
1 parent dfa34d0 commit d1037ce

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

cmd/coordinator/coordinator.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,23 @@ func findWork(work chan<- buildgo.BuilderRev) error {
733733
knownToDashboard[b] = true
734734
}
735735

736+
// Before, we just sent all the possible work to workc,
737+
// which then kicks off lots of goroutines that fight over
738+
// available buildlets, with the result that we run a random
739+
// subset of the possible work. But really we want to run
740+
// the newest possible work, so that lines at the top of the
741+
// build dashboard are filled in before lines below.
742+
// It's a bit hard to push that preference all the way through
743+
// this code base, but we can tilt the scales a little by only
744+
// sending one job to workc for each different builder
745+
// on each findWork call. The findWork calls happen every
746+
// 15 seconds, so we will now only kick off one build of
747+
// a particular host type (for example, darwin-arm64) every
748+
// 15 seconds, but they should be skewed toward new work.
749+
// This depends on the build dashboard sending back the list
750+
// of empty slots newest first (matching the order on the main screen).
751+
sent := map[string]bool{}
752+
736753
var goRevisions []string // revisions of repo "go", branch "master" revisions
737754
seenSubrepo := make(map[string]bool)
738755
for _, br := range bs.Revisions {
@@ -803,7 +820,12 @@ func findWork(work chan<- buildgo.BuilderRev) error {
803820
if skipBuild(rev) {
804821
continue
805822
}
806-
if !isBuilding(rev) {
823+
824+
// The !sent[builder] here is a clumsy attempt at priority scheduling
825+
// and probably should be replaced at some point with a better solution.
826+
// See golang.org/issue/19178 and the long comment above.
827+
if !isBuilding(rev) && !sent[builder] {
828+
sent[builder] = true
807829
work <- rev
808830
}
809831
}

0 commit comments

Comments
 (0)