]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: use m.profStack in traceStack
authorMichael Anthony Knyszek <mknyszek@google.com>
Wed, 19 Nov 2025 23:42:06 +0000 (23:42 +0000)
committerGopher Robot <gobot@golang.org>
Mon, 24 Nov 2025 21:20:13 +0000 (13:20 -0800)
Turns out we spend a few percent of the trace event writing path in just
zero-initializing the stack space for pcBuf. We don't need zero
initialization, since we're going to write over whatever we actually
use. Use m.profStack instead, which is already sized correctly.

A side-effect of this change is that trace stacks now obey the GODEBUG
profstackdepth where they previously ignored it. The name clearly
doesn't match, but this is a positive: there's no reason the maximum
stack depth shouldn't apply to every diagnostic.

Change-Id: Ia654d3d708f15cbb2e1d95af196ae10b07a65df2
Reviewed-on: https://go-review.googlesource.com/c/go/+/723062
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>

src/runtime/tracestack.go

index 0da217fba98f003e89997dae3565352814c6e396..d3f217bbacedc8d1f5b1c99fa0a2a79562beee4c 100644 (file)
@@ -30,7 +30,7 @@ const (
 //
 // Avoid calling this function directly. Prefer traceEventWriter.stack.
 func traceStack(skip int, gp *g, tab *traceStackTable) uint64 {
-       var pcBuf [tracev2.MaxFramesPerStack]uintptr
+       pcBuf := getg().m.profStack
 
        // Figure out gp and mp for the backtrace.
        var mp *m