aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/proc.go
diff options
context:
space:
mode:
authorFelix Geisendörfer <felix.geisendoerfer@datadoghq.com>2024-04-27 13:41:05 +0200
committerAustin Clements <austin@google.com>2024-05-21 14:38:56 +0000
commit66cc2b7ca760d62294584d6680df65892cf7a8cf (patch)
tree829a235416aa5419b89ab6c96ebef0211fa3fd00 /src/runtime/proc.go
parent1b9dc3e178be578cf1d8c06fe371283a58bdd93f (diff)
downloadgo-66cc2b7ca760d62294584d6680df65892cf7a8cf.tar.xz
runtime: make profstackdepth a GODEBUG option
Allow users to decrease the profiling stack depth back to 32 in case they experience any problems with the new default of 128. Users may also use this option to increase the depth up to 1024. Change-Id: Ieaab2513024915a223239278dd97a6e161dde1cf Reviewed-on: https://go-review.googlesource.com/c/go/+/581917 Reviewed-by: Austin Clements <austin@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'src/runtime/proc.go')
-rw-r--r--src/runtime/proc.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/runtime/proc.go b/src/runtime/proc.go
index a9d60faa69..12f26fbb6c 100644
--- a/src/runtime/proc.go
+++ b/src/runtime/proc.go
@@ -818,6 +818,9 @@ func schedinit() {
MemProfileRate = 0
}
+ // mcommoninit runs before parsedebugvars, so init profstacks again.
+ mProfStackInit(gp.m)
+
lock(&sched.lock)
sched.lastpoll.Store(nanotime())
procs := ncpu
@@ -930,6 +933,11 @@ func mcommoninit(mp *m, id int64) {
// malloc and runtime locks for mLockProfile.
// TODO(mknyszek): Implement lazy allocation if this becomes a problem.
func mProfStackInit(mp *m) {
+ if debug.profstackdepth == 0 {
+ // debug.profstack is set to 0 by the user, or we're being called from
+ // schedinit before parsedebugvars.
+ return
+ }
mp.profStack = makeProfStackFP()
mp.mLockProfile.stack = makeProfStackFP()
}
@@ -944,12 +952,12 @@ func makeProfStackFP() []uintptr {
// The "maxSkip" term is for frame pointer unwinding, where we
// want to end up with debug.profstackdebth frames but will discard
// some "physical" frames to account for skipping.
- return make([]uintptr, 1+maxSkip+maxLogicalStack)
+ return make([]uintptr, 1+maxSkip+debug.profstackdepth)
}
// makeProfStack returns a buffer large enough to hold a maximum-sized stack
// trace.
-func makeProfStack() []uintptr { return make([]uintptr, maxLogicalStack) }
+func makeProfStack() []uintptr { return make([]uintptr, debug.profstackdepth) }
//go:linkname pprof_makeProfStack
func pprof_makeProfStack() []uintptr { return makeProfStack() }