]> Cypherpunks repositories - gostls13.git/commitdiff
test/heapsampling.go: slow down allocation rate and reduce iterations
authorMichael Anthony Knyszek <mknyszek@google.com>
Fri, 27 May 2022 18:14:58 +0000 (18:14 +0000)
committerMichael Knyszek <mknyszek@google.com>
Fri, 27 May 2022 21:36:06 +0000 (21:36 +0000)
As far as I can tell, this test suffers from #52433. For some reason,
this seems to become more of a problem on the windows/386 than anywhere
else. This CL is an attempt at a mitigation by slowing down the
allocation rate by inserting runtime.Gosched call in the inner loop. It
also cuts the iteration count which should help too (as less memory is
allocated in total), but the main motivation is to make sure the test
doesn't take too long to run.

Fixes #49564.

Change-Id: I8cc622b06a69cdfa66f680a30e1ccf334eea2164
Reviewed-on: https://go-review.googlesource.com/c/go/+/408825
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

test/heapsampling.go

index cc72832ab48d4680eccb1bd24eacd818fda7b9b9..741db74f894d454227e869baa6e8c82e66b470d2 100644 (file)
@@ -45,7 +45,7 @@ func main() {
 // the testcase allows for a 10% margin of error, but only fails if it
 // consistently fails across three experiments, avoiding flakes.
 func testInterleavedAllocations() error {
-       const iters = 100000
+       const iters = 50000
        // Sizes of the allocations performed by each experiment.
        frames := []string{"main.allocInterleaved1", "main.allocInterleaved2", "main.allocInterleaved3"}
 
@@ -79,6 +79,9 @@ func allocInterleaved(n int) {
                a16k = new([16 * 1024]byte)
                a256 = new([256]byte)
                // Test verification depends on these lines being contiguous.
+
+               // Slow down the allocation rate to avoid #52433.
+               runtime.Gosched()
        }
 }
 
@@ -101,7 +104,7 @@ func allocInterleaved3(n int) {
 // the testcase allows for a 10% margin of error, but only fails if it
 // consistently fails across three experiments, avoiding flakes.
 func testSmallAllocations() error {
-       const iters = 100000
+       const iters = 50000
        // Sizes of the allocations performed by each experiment.
        sizes := []int64{1024, 512, 256}
        frames := []string{"main.allocSmall1", "main.allocSmall2", "main.allocSmall3"}
@@ -130,6 +133,9 @@ func allocSmall(n int) {
                a1k = new([1024]byte)
                a512 = new([512]byte)
                a256 = new([256]byte)
+
+               // Slow down the allocation rate to avoid #52433.
+               runtime.Gosched()
        }
 }