Skip to content

Commit a93e9f0

Browse files
committed
cmd/dist: spin up fewer test dir runners
5 shards, each of which spins up NumCPU processes, each of which is running at GOMAXPROCS=NumCPU, is too much for one machine. It makes my laptop unusable. It might also be in part responsible for test flakes that require a moderately responsive system, like #18589 (backedge scheduling) and #19276 (locklinear). It's possible that Go should be a better neighbor in general; that's #17969. In the meantime, fix this corner of the world. Builders snapshot the world and run shards on different machines, so keeping sharding high for them is good. This is a partial reversion of CL 18199. Fixes #20141. Change-Id: I123cf9436f4f4da3550372896265c38117b78071 Reviewed-on: https://go-review.googlesource.com/42431 Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 18fb670 commit a93e9f0

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/cmd/dist/test.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,13 @@ func (t *tester) registerTests() {
597597
t.registerTest("bench_go1", "../test/bench/go1", "go", "test", t.timeout(600), t.runFlag(""))
598598
}
599599
if t.goos != "android" && !t.iOS() {
600-
const nShards = 5
600+
// Only start multiple test dir shards on builders,
601+
// where they get distributed to multiple machines.
602+
// See issue 20141.
603+
nShards := 1
604+
if os.Getenv("GO_BUILDER_NAME") != "" {
605+
nShards = 10
606+
}
601607
for shard := 0; shard < nShards; shard++ {
602608
shard := shard
603609
t.tests = append(t.tests, distTest{
@@ -1143,7 +1149,7 @@ func (t *tester) testDirTest(dt *distTest, shard, shards int) error {
11431149
runtest.Do(func() {
11441150
const exe = "runtest.exe" // named exe for Windows, but harmless elsewhere
11451151
cmd := t.dirCmd("test", "go", "build", "-o", exe, "run.go")
1146-
cmd.Env = append(os.Environ(), "GOOS="+t.gohostos, "GOARCH="+t.gohostarch, "GOMAXPROCS=")
1152+
cmd.Env = append(os.Environ(), "GOOS="+t.gohostos, "GOARCH="+t.gohostarch)
11471153
runtest.exe = filepath.Join(cmd.Dir, exe)
11481154
if err := cmd.Run(); err != nil {
11491155
runtest.err = err

0 commit comments

Comments
 (0)