runtime/pprof: update test's expected frame count

The recent work on size-specialized malloc changed the number of frames
that appear in the memory profile when allocation takes the slow path.

Now, the fast path results in 4 frames, the slow path results in 5, and
race builds (which disable size-specialized malloc) have 6. The test was
expecting either 4 or 6. The recent test flakes were likely due to the
GC running concurrently with the test, which would trigger
mallocgcSmallScanNoHeaderSC4's check of gcBlackenEnabled != 0.

We can confirm by running the test with GODEBUG=traceallocfree=1 and
the -trace flag, which forces the slow path.

Fixes #79528

Change-Id: I119d0f275e7c3527e4a12d5dc2138071679349e7
Reviewed-on: https://go-review.googlesource.com/c/go/+/781680
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Rhys Hiltner <rhys.hiltner@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Richard Miller <millerresearch@gmail.com>
This commit is contained in:
Rhys Hiltner 2026-05-21 15:05:16 -07:00 committed by Gopher Robot
parent e4283592e5
commit cc623858f6

View file

@ -96,8 +96,11 @@ func TestMemoryProfiler(t *testing.T) {
stk []string
legacy string
}{{
// 4 PCs for the fast path
// 5 PCs for the slow path with size-specialized malloc
// 6 PCs for race builds (which also disable size-specialized malloc)
stk: []string{"runtime/pprof.allocatePersistent1K", "runtime/pprof.TestMemoryProfiler"},
legacy: fmt.Sprintf(`%v: %v \[%v: %v\] @ 0x[0-9,a-f]+ 0x[0-9,a-f]+ 0x[0-9,a-f]+ 0x[0-9,a-f]+( 0x[0-9,a-f]+ 0x[0-9,a-f]+)?
legacy: fmt.Sprintf(`%v: %v \[%v: %v\] @( 0x[0-9,a-f]+){4,6}
# 0x[0-9,a-f]+ runtime/pprof\.allocatePersistent1K\+0x[0-9,a-f]+ .*runtime/pprof/mprof_test\.go:48
# 0x[0-9,a-f]+ runtime/pprof\.TestMemoryProfiler\+0x[0-9,a-f]+ .*runtime/pprof/mprof_test\.go:87
`, 32*memoryProfilerRun, 1024*memoryProfilerRun, 32*memoryProfilerRun, 1024*memoryProfilerRun),