From: Michael Anthony Knyszek Date: Wed, 19 Nov 2025 23:42:06 +0000 (+0000) Subject: runtime: use m.profStack in traceStack X-Git-Tag: go1.26rc1~145 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=7fbd141de506e331ef3f5910b505ece91a012e4a;p=gostls13.git runtime: use m.profStack in traceStack 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 Reviewed-by: Michael Pratt Auto-Submit: Michael Knyszek --- diff --git a/src/runtime/tracestack.go b/src/runtime/tracestack.go index 0da217fba9..d3f217bbac 100644 --- a/src/runtime/tracestack.go +++ b/src/runtime/tracestack.go @@ -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