-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
runtime/pprof: Missing labels from goroutines stacks containing systemstack #48577
Comments
Change https://golang.org/cl/351751 mentions this issue: |
Use gp.m.curg instead of the gp when recording cpu profiler stack traces. This ensures profiler labels are captured when systemstack or similar is executing on behalf of the current goroutine. After this there are still rare cases of samples containing the labelHog function, so more work might be needed. This patch should fix ~99% of the problem. Fixes golang#48577. Change-Id: I27132110e3d09721ec3b3ef417122bc70d8f3279
Reverted in https://golang.org/cl/360757 due to broken builders on the new test. |
Change https://golang.org/cl/362614 mentions this issue: |
For tests of pprof label support having the sample labels in the output is needed for effective debugging. For #48577 Change-Id: Ic7c5bc90cb33e8fb477f7db62d9b56a7a9d6ffa8 Reviewed-on: https://go-review.googlesource.com/c/go/+/362614 Trust: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
Change https://golang.org/cl/367200 mentions this issue: |
Update: Turns out this issue also impacted cgo stacks, which pretty much never have labels in go1.17 in my testing. However, CL 367200 seems to have also fixed the cgo case 🥳 |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I created a Go program like
cpu-profiler-label-bug.go
shown below that uses pprof labels and generates a CPU profile:I then executed the program and used pprofutils labelframes to turn
cpu.pprof
intocpu.label.pprof
. The latter modifies each sample in the pprof to add a new root frame that contains the value of my labelfoo
(or N/A if the label is not present). This makes it easier to view the labels than in the graph view of pprof.What did you expect to see?
main.cpuHog
should show up only under thefoo=bar
frame and not thefoo=N/A
frame:What did you see instead?
3.95% of all samples containing
main.cpuHog
show below thefoo=N/A
frame which means they were missing thefoo=bar
label.Zooming into those 3.95% of the flame graph, I noticed that most samples contain a
systemstack
frame.See zip file below for code, pprofs and screenshots: cpu-profiler-label-bug.zip
My Analysis
As far as I can tell this problem can be easily fixed via the patch below. In fact that's what I used to create the "What did you expect to see" screenshot above.
The reason this is the right thing to do is because
gp.m.curg
should always point to the right goroutine, even when the systemstack goroutine is executing. At least that's how traceback.go stitches the stacks together.Since I suspect this to be the correct fix, I'll be submitting a CL shortly. It's like to fix more situations as well (
morestack
,newstack
, etc.)The text was updated successfully, but these errors were encountered: