diff options
author | Keith Randall <khr@golang.org> | 2014-10-20 15:48:42 -0700 |
---|---|---|
committer | Keith Randall <khr@golang.org> | 2014-10-20 15:48:42 -0700 |
commit | 3ec8fe45cf4190a55f692f7c6e42936f9d912d36 (patch) | |
tree | d2e3c30bcc8840304f0fdc4d48e0203392817b4e /src/runtime/mprof.go | |
parent | 9d06cfc810692911372b80b7ef0dc080ee1d34d4 (diff) | |
download | go-3ec8fe45cf4190a55f692f7c6e42936f9d912d36.tar.gz go-3ec8fe45cf4190a55f692f7c6e42936f9d912d36.zip |
runtime: fix flaky TestBlockProfile test
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
Diffstat (limited to 'src/runtime/mprof.go')
-rw-r--r-- | src/runtime/mprof.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/runtime/mprof.go b/src/runtime/mprof.go index f4676fad6e..803da56670 100644 --- a/src/runtime/mprof.go +++ b/src/runtime/mprof.go @@ -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) { |