-
Notifications
You must be signed in to change notification settings - Fork 18k
runtime: add 'created by goroutine number' to stack traces #38651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
We'd need to add this to the g struct and print it. |
This proposal has been added to the active column of the proposals project |
Does anyone object to adding this? |
I'd rather want to see pprof.Labels in stacktraces, as I suggested in linked issue. But if adding parent goroutine ID is easy to do then why not I guess. |
It seems to me that this would not give access to a full tree view into the goroutine's origins since when we have the creator's ID, we cannot easily step beyond that to its creator since we have an ID, not a |
@kortschak The only time I can think of that you'd be building a tree view of goroutines is during a debug session. In that case the debugger could build a map from ID to |
Parent goroutine can very well be gone at any point while the child is still running. Will knowing ID be even useful in that case? |
@kaey Good point and probably a good reason why we couldn't add It's been a while since I created this and I don't honestly remember what my motivation was. I think the main issue is figuring out what caused a goroutine to be spawned. If the parent is dead and I don't know the parent's parent, then knowing the parent's ID is probably useless. However if I am able to reconstruct the goroutine chain, I might be able to figure out the chain of events that lead to the last goroutine getting spawned. The cases I can think of are things like an event loop spawning goroutines to process events, or a socket accept loop spawning goroutines to handle connections. In those cases the parent goroutine should be long-lived. |
This is very simple to implement. It has limitations that more comprehensive schemes might not, but it's still very likely useful on its own, far in excess of its cost. So it sounds like we should do this, and we can leave any suggested heavier schemes for other proposals. |
Based on the discussion above, this proposal seems like a likely accept. |
No change in consensus, so accepted. 🎉 |
Change https://go.dev/cl/435337 mentions this issue: |
Fixes golang#38651 Change-Id: Id46d684ee80e208c018791a06c26f304670ed159 Reviewed-on: https://go-review.googlesource.com/c/go/+/435337 Run-TryBot: Nick Ripley <[email protected]> Reviewed-by: Ethan Reesor <[email protected]> Auto-Submit: Michael Pratt <[email protected]> Reviewed-by: Michael Pratt <[email protected]> Reviewed-by: Cherry Mui <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
Change https://go.dev/cl/501336 mentions this issue: |
For #38651. Change-Id: Ie73c1da0629287efda7f0c617e94a7f3a881eee7 Reviewed-on: https://go-review.googlesource.com/c/go/+/501336 Reviewed-by: Eli Bendersky <[email protected]> TryBot-Bypass: Michael Knyszek <[email protected]> Auto-Submit: Michael Knyszek <[email protected]> Reviewed-by: Austin Clements <[email protected]>
Per @ianlancetaylor's comment on #35178 (comment), I propose improving the debugging experience by including goroutine tree information in stack dumps and providing that information to debuggers (delve).
I propose that
created by file.go:col
in stack dumps is expanded tocreated by goroutine # at file.go:col
, and that goroutine tree information is provided to debuggers like delve.Ian's original comment:
The text was updated successfully, but these errors were encountered: