diff options
Diffstat (limited to 'src/pkg/time/internal_test.go')
-rw-r--r-- | src/pkg/time/internal_test.go | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/pkg/time/internal_test.go b/src/pkg/time/internal_test.go index 87fdd3216..2243d3668 100644 --- a/src/pkg/time/internal_test.go +++ b/src/pkg/time/internal_test.go @@ -29,16 +29,20 @@ func CheckRuntimeTimerOverflow() error { // detection logic in NewTimer: we're testing the underlying // runtime.addtimer function. r := &runtimeTimer{ - when: nano() + (1<<63 - 1), + when: runtimeNano() + (1<<63 - 1), f: empty, arg: nil, } startTimer(r) timeout := 100 * Millisecond - if runtime.GOOS == "windows" { - // Allow more time for gobuilder to succeed. + switch runtime.GOOS { + // Allow more time for gobuilder to succeed. + case "windows": timeout = Second + case "plan9": + // TODO(0intro): We don't know why it is needed. + timeout = 3 * Second } // Start a goroutine that should send on t.C before the timeout. @@ -74,7 +78,15 @@ func CheckRuntimeTimerOverflow() error { if Now().After(stop) { return errors.New("runtime timer stuck: overflow in addtimer") } - runtime.Gosched() + // Issue 6874. This test previously called runtime.Gosched to try to yield + // to the goroutine servicing t, however the scheduler has a bias towards the + // previously running goroutine in an idle system. Combined with high load due + // to all CPUs busy running tests t's goroutine could be delayed beyond the + // timeout window. + // + // Calling runtime.GC() reduces the worst case lantency for scheduling t by 20x + // under the current Go 1.3 scheduler. + runtime.GC() } } } |