Commit f2c3957e authored by Austin Clements's avatar Austin Clements

runtime: disable GC around TestGoroutineParallelism

TestGoroutineParallelism can deadlock if the GC runs during the
test. Currently it tries to prevent this by forcing a GC before the
test, but this is best effort and fails completely if GOGC is very low
for testing.

This change replaces this best-effort fix with simply setting GOGC to
off for the duration of the test.

Change-Id: I8229310833f241b149ebcd32845870c1cb14e9f8
Reviewed-on: https://go-review.googlesource.com/10454Reviewed-by: default avatarRuss Cox <rsc@golang.org>
parent f90d802b
...@@ -7,6 +7,7 @@ package runtime_test ...@@ -7,6 +7,7 @@ package runtime_test
import ( import (
"math" "math"
"runtime" "runtime"
"runtime/debug"
"sync" "sync"
"sync/atomic" "sync/atomic"
"syscall" "syscall"
...@@ -104,8 +105,8 @@ func TestGoroutineParallelism(t *testing.T) { ...@@ -104,8 +105,8 @@ func TestGoroutineParallelism(t *testing.T) {
defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(P)) defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(P))
// If runtime triggers a forced GC during this test then it will deadlock, // If runtime triggers a forced GC during this test then it will deadlock,
// since the goroutines can't be stopped/preempted. // since the goroutines can't be stopped/preempted.
// So give this test as much time as possible. // Disable GC for this test (see issue #10958).
runtime.GC() defer debug.SetGCPercent(debug.SetGCPercent(-1))
for try := 0; try < N; try++ { for try := 0; try < N; try++ {
done := make(chan bool) done := make(chan bool)
x := uint32(0) x := uint32(0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment