Skip to content

Commit c087121

Browse files
committed
runtime: relax the threshold for TestPingPongHog
The test checks that the scheduling of the goroutines are within a small factor, to ensure the scheduler handing off the P correctly. There have been flaky failures on the builder (probably due to OS scheduling delays). Increase the threshold to make it less flaky. The gap would be much bigger if the scheduler doesn't work correctly. For the long term maybe it is better to test it more directly with the scheduler, e.g. with scheduler instrumentation. May fix #52207. Change-Id: I50278b70ab21b7f04761fdc8b38dd13304c67879 Reviewed-on: https://go-review.googlesource.com/c/go/+/407134 TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Bryan Mills <[email protected]> Run-TryBot: Cherry Mui <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Reviewed-by: Michael Knyszek <[email protected]>
1 parent fe4de36 commit c087121

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/runtime/proc_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,11 +477,12 @@ func TestPingPongHog(t *testing.T) {
477477
<-lightChan
478478

479479
// Check that hogCount and lightCount are within a factor of
480-
// 5, which indicates that both pairs of goroutines handed off
480+
// 20, which indicates that both pairs of goroutines handed off
481481
// the P within a time-slice to their buddy. We can use a
482482
// fairly large factor here to make this robust: if the
483-
// scheduler isn't working right, the gap should be ~1000X.
484-
const factor = 5
483+
// scheduler isn't working right, the gap should be ~1000X
484+
// (was 5, increased to 20, see issue 52207).
485+
const factor = 20
485486
if hogCount > lightCount*factor || lightCount > hogCount*factor {
486487
t.Fatalf("want hogCount/lightCount in [%v, %v]; got %d/%d = %g", 1.0/factor, factor, hogCount, lightCount, float64(hogCount)/float64(lightCount))
487488
}

0 commit comments

Comments
 (0)