Skip to content

Commit 0bbd67e

Browse files
committed
runtime/pprof: document possibility of empty stacks
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 <[email protected]> Run-TryBot: Austin Clements <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Michael Pratt <[email protected]>
1 parent d9f23cf commit 0bbd67e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/runtime/pprof/proto.go

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

0 commit comments

Comments
 (0)