]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: fix flaky TestBlockProfile test
authorKeith Randall <khr@golang.org>
Mon, 20 Oct 2014 22:48:42 +0000 (15:48 -0700)
committerKeith Randall <khr@golang.org>
Mon, 20 Oct 2014 22:48:42 +0000 (15:48 -0700)
It has been failing periodically on Solaris/x64.
Change blockevent so it always records an event if we called
SetBlockProfileRate(1), even if the time delta is negative or zero.

Hopefully this will fix the test on Solaris.
Caveat: I don't actually know what the Solaris problem is, this
is just an educated guess.

LGTM=dave
R=dvyukov, dave
CC=golang-codereviews
https://golang.org/cl/159150043

src/runtime/mprof.go

index f4676fad6e30ead6f6c69ca160db4ecd6f94f043..803da56670bd9eb1215d92ef7d7894db1cd2656b 100644 (file)
@@ -284,6 +284,8 @@ func SetBlockProfileRate(rate int) {
        var r int64
        if rate <= 0 {
                r = 0 // disable profiling
+       } else if rate == 1 {
+               r = 1 // profile everything
        } else {
                // convert ns to cycles, use float64 to prevent overflow during multiplication
                r = int64(float64(rate) * float64(tickspersecond()) / (1000 * 1000 * 1000))
@@ -297,7 +299,7 @@ func SetBlockProfileRate(rate int) {
 
 func blockevent(cycles int64, skip int) {
        if cycles <= 0 {
-               return
+               cycles = 1
        }
        rate := int64(atomicload64(&blockprofilerate))
        if rate <= 0 || (rate > cycles && int64(fastrand1())%rate > cycles) {