aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/pprof
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2021-04-06 10:23:48 -0400
committerCherry Zhang <cherryyz@google.com>2021-04-06 18:01:39 +0000
commit55bac87bd690d5812b3e6640977a0568f14c0715 (patch)
treec39f5a1fa7f1dd5507b840e277c726cfc48092be /src/runtime/pprof
parentb345a306a0258085b65081cf2dadc238dc7e26ee (diff)
downloadgo-55bac87bd690d5812b3e6640977a0568f14c0715.tar.gz
go-55bac87bd690d5812b3e6640977a0568f14c0715.zip
runtime/pprof: deflake TestMorestack
In TestMorestack, on macOS, for some reason it got most of the samples in synchronization (e.g. pthread_cond_signal and pthread_cond_wait) and sometimes in other "syscalls" (usleep, nanotime1), and very few samples in stack copying, sometimes 0, which causes the test to fail. Maybe synchronization is slower on macOS? (It doesn't seem so to me.) Or it is the OS's accounting problem, where it is more likely to trigger a profiling signal at a syscall (or certain kinds of syscalls)? As the test is really about whether it can connect stack copying with the function that grows the stack, this CL makes it spend more time in copying stack than synchronization. Now it's getting ~100 samples for stack copying on a 5 second interval on my machine, and the test passes reliably. Fixes #44418. Change-Id: I3a462c8c39766f2d67d697598f8641bbe64f16ad Reviewed-on: https://go-review.googlesource.com/c/go/+/307730 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src/runtime/pprof')
-rw-r--r--src/runtime/pprof/pprof_test.go24
1 files changed, 7 insertions, 17 deletions
diff --git a/src/runtime/pprof/pprof_test.go b/src/runtime/pprof/pprof_test.go
index e6b4d0044d..3423f8dc3d 100644
--- a/src/runtime/pprof/pprof_test.go
+++ b/src/runtime/pprof/pprof_test.go
@@ -12,7 +12,6 @@ import (
"context"
"fmt"
"internal/profile"
- "internal/race"
"internal/testenv"
"io"
"math/big"
@@ -586,18 +585,6 @@ func stackContainsAll(spec string, count uintptr, stk []*profile.Location, label
}
func TestMorestack(t *testing.T) {
- if runtime.GOOS == "darwin" && race.Enabled {
- // For whatever reason, using the race detector on macOS keeps us
- // from finding the newstack/growstack calls in the profile.
- // Not worth worrying about.
- // https://build.golang.org/log/280d387327806e17c8aabeb38b9503dbbd942ed1
- t.Skip("skipping on darwin race detector")
- }
- if runtime.GOOS == "darwin" && runtime.GOARCH == "arm64" {
- // For whatever reason, darwin/arm64 also doesn't work.
- // https://build.golang.org/log/c45e82cc25f152642e6fb90d882ef5a8cd130ce5
- t.Skip("skipping on darwin/arm64")
- }
testCPUProfile(t, stackContainsAll, []string{"runtime.newstack,runtime/pprof.growstack"}, avoidFunctions(), func(duration time.Duration) {
t := time.After(duration)
c := make(chan bool)
@@ -617,17 +604,20 @@ func TestMorestack(t *testing.T) {
//go:noinline
func growstack1() {
- growstack()
+ growstack(10)
}
//go:noinline
-func growstack() {
- var buf [8 << 10]byte
+func growstack(n int) {
+ var buf [8 << 16]byte
use(buf)
+ if n > 0 {
+ growstack(n - 1)
+ }
}
//go:noinline
-func use(x [8 << 10]byte) {}
+func use(x [8 << 16]byte) {}
func TestBlockProfile(t *testing.T) {
type TestCase struct {