diff options
author | Xiangdong Ji <xiangdong.ji@arm.com> | 2019-12-05 03:22:34 +0000 |
---|---|---|
committer | Michael Knyszek <mknyszek@google.com> | 2020-03-26 14:23:17 +0000 |
commit | f9c5ef8d8f94b364c758930f64b9305c52200b5b (patch) | |
tree | 5a8167dbd83267311a2011c64e47aeb78c4d2158 /src/runtime/testdata | |
parent | 2975b27bbd3d4e85a2488ac289e112bc0dedfebe (diff) | |
download | go-f9c5ef8d8f94b364c758930f64b9305c52200b5b.tar.gz go-f9c5ef8d8f94b364c758930f64b9305c52200b5b.zip |
runtime: fix threshold calculation of TestPhysicalMemoryUtilization
Variable 'procs' used to calculate the threshold of overuse in
TestPhysicalMemoryUtilization should be updated if GOMAXPROCS
gets changed, otherwise the threshold could be a large number,
making the test meaningless.
Change-Id: I876cbf11457529f56bae77af1e35f4538a721f95
Reviewed-on: https://go-review.googlesource.com/c/go/+/210297
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'src/runtime/testdata')
-rw-r--r-- | src/runtime/testdata/testprog/gc.go | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/runtime/testdata/testprog/gc.go b/src/runtime/testdata/testprog/gc.go index cc16413ef5..f691a1d127 100644 --- a/src/runtime/testdata/testprog/gc.go +++ b/src/runtime/testdata/testprog/gc.go @@ -150,16 +150,20 @@ func GCPhys() { // The page cache could hide 64 8-KiB pages from the scavenger today. maxPageCache = (8 << 10) * 64 + + // Reduce GOMAXPROCS down to 4 if it's greater. We need to bound the amount + // of memory held in the page cache because the scavenger can't reach it. + // The page cache will hold at most maxPageCache of memory per-P, so this + // bounds the amount of memory hidden from the scavenger to 4*maxPageCache + // at most. + maxProcs = 4 ) // Set GOGC so that this test operates under consistent assumptions. debug.SetGCPercent(100) - // Reduce GOMAXPROCS down to 4 if it's greater. We need to bound the amount - // of memory held in the page cache because the scavenger can't reach it. - // The page cache will hold at most maxPageCache of memory per-P, so this - // bounds the amount of memory hidden from the scavenger to 4*maxPageCache. procs := runtime.GOMAXPROCS(-1) - if procs > 4 { - defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(4)) + if procs > maxProcs { + defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(maxProcs)) + procs = runtime.GOMAXPROCS(-1) } // Save objects which we want to survive, and condemn objects which we don't. // Note that we condemn objects in this way and release them all at once in |