]> Cypherpunks repositories - gostls13.git/commit
runtime/pprof: plumb labels for goroutine profiles
authorDavid Finkel <david.finkel@gmail.com>
Sun, 4 Aug 2019 19:14:48 +0000 (15:14 -0400)
committerHyang-Ah Hana Kim <hyangah@gmail.com>
Wed, 22 Apr 2020 16:01:25 +0000 (16:01 +0000)
commit38c2c12bc1b3da40e1b33cac9268b7df9fa49a7e
treed420fecda8b99294301f913db08fcf20777e6c21
parent0329c915a03199d202581d0b33b092371fde08dc
runtime/pprof: plumb labels for goroutine profiles

Goroutines are directly associated with labels. It's relatively easy to
plumb those through without creating goroutine-locals in the wild.

This is accomplished by splitting out most of the code from the public
`runtime.GoroutineProfile` into a new unexported
`runtime.goroutineProfileWithLabels`, which then has a thin wrapper
linked into the `runtime/pprof` package as
`runtime_goroutineProfileWithLabels`. (mirroring the way labels get
associated with the `g` for a goroutine in the first place)

Per-#6104, OS-thread creation profiles are a bit useless, as `M`s tend
to be created be created by a background goroutine. As such, I decided
not to add support for capturing the labels at `M`-creation-time, since
the stack-traces seem to always come out `nil` for my simple test
binaries.

This change currently provides labels for debug=0 and debug=1, as
debug=2 is currently entirely generated by the runtime package and I
don't see a clean way of getting the `labelMap` type handled properly
within the `runtime` package.

Update the comment added in cl/131275 to mention goroutine support for
labels.

Updates #23458

Change-Id: Ia4b558893d7d10156b77121cd9b70c4ccd9e1889
Reviewed-on: https://go-review.googlesource.com/c/go/+/189318
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
src/runtime/mprof.go
src/runtime/pprof/label.go
src/runtime/pprof/label_test.go
src/runtime/pprof/pprof.go
src/runtime/pprof/pprof_test.go