mirror of
https://github.com/golang/go.git
synced 2025-10-19 19:13:18 +00:00
sync: set GOMAXPROCS to 1 in TestPoolGC
This test expects to be able to drain a Pool using only Get. This isn't actually possible in the general case, since a pooled value could get stuck in some P's private slot. However, if GOMAXPROCS=1, there's only 1 P we could be running on, so getting stuck becomes impossible. This test isn't checking any concurrent properties of Pool, so this is fine. Just set GOMAXPROCS=1 for this one particular test. Fixes #73728. Change-Id: I9053e28118060650f2cd7d0d58f5a86d630b36f7 Reviewed-on: https://go-review.googlesource.com/c/go/+/673375 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com>
This commit is contained in:
parent
2b3794e3e8
commit
e6cd9c083e
1 changed files with 12 additions and 0 deletions
|
@ -102,6 +102,18 @@ func TestPoolRelease(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testPool(t *testing.T, drain bool) {
|
func testPool(t *testing.T, drain bool) {
|
||||||
|
if drain {
|
||||||
|
// Run with GOMAXPROCS=1 if drain is set. The code below implicitly
|
||||||
|
// assumes it can remove all the pool-cached values with cleanups
|
||||||
|
// with Get, but this isn't necessarily true if a value gets stuck
|
||||||
|
// in the private slot for some P. This is especially likely when
|
||||||
|
// running with mayMoreStackPreempt. We can make this exact, however,
|
||||||
|
// by setting GOMAXPROCS to 1, so there's only 1 P. This is fine for
|
||||||
|
// this test, since we're not trying to check any concurrent properties
|
||||||
|
// of Pool anyway.
|
||||||
|
defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(1))
|
||||||
|
}
|
||||||
|
|
||||||
var p Pool
|
var p Pool
|
||||||
const N = 100
|
const N = 100
|
||||||
for try := 0; try < 3; try++ {
|
for try := 0; try < 3; try++ {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue