]> Cypherpunks repositories - gostls13.git/commitdiff
runtime/pprof: document possibility of empty stacks
authorAustin Clements <austin@google.com>
Thu, 5 Jan 2023 14:08:25 +0000 (09:08 -0500)
committerAustin Clements <austin@google.com>
Mon, 9 Jan 2023 20:25:19 +0000 (20:25 +0000)
I spent quite a while determining the cause of empty stacks in
profiles and reasoning out why this is okay. There isn't a great place
to record this knowledge, but a documentation comment on
appendLocsForStack is better than nothing.

Updates #51550.

Change-Id: I2eefc6ea31f1af885885c3d96199319f45edb4ce
Reviewed-on: https://go-review.googlesource.com/c/go/+/460695
Reviewed-by: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
src/runtime/pprof/proto.go

index 8a49e144b995bdd0c40ab5051088a094a8d63d56..b68f30d923162c64fdb2d425c6a2ca7ddac55383 100644 (file)
@@ -395,6 +395,10 @@ func (b *profileBuilder) build() {
 // location ID slice, locs. The addresses in the stack are return PCs or 1 + the PC of
 // an inline marker as the runtime traceback function returns.
 //
+// It may return an empty slice even if locs is non-empty, for example if locs consists
+// solely of runtime.goexit. We still count these empty stacks in profiles in order to
+// get the right cumulative sample count.
+//
 // It may emit to b.pb, so there must be no message encoding in progress.
 func (b *profileBuilder) appendLocsForStack(locs []uint64, stk []uintptr) (newLocs []uint64) {
        b.deck.reset()