-
-
Notifications
You must be signed in to change notification settings - Fork 142
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
[DRAFT] "Stack" Tracing #355
Comments
In general, I think we should try to prefer whichever approach makes the |
We may want to do some actual benchmarking, here. It could be good to measure the performance impact of adding the |
I have to say, without this feature this project is of little use. What am I supposed to learn from scheduler park latencies per task? How is this helping any "debugging" effort? Having a grasp of where the tasks are parked would be the very first thing I'd expect this debugger to implement. The next thing would be values captured by the futures. You know, how every actual debugger works? Without this we have no way to understand where walltime is actually spent. And of course regular debugging tools don't work with async because all the thread stacktraces point into the scheduler. Side note, of course the span-based approach will not scale properly in terms of performance. What we'd actually need is a sampler for the task states, but I don't even know where one would begin doing that, you'd need to map parked future states back to un-desugared code. So you'd need... well, something like DWARF, surprise surprise. |
You might be interested in looking at the task dump feature in tokio which the author of this draft implemented: https://docs.rs/tokio/latest/tokio/runtime/struct.Handle.html#method.dump We have no integration for this feature with tokio-console, although it would definitely be nice to have. Having said that, if you want a low level profiler, then tokio-console is not currently offering that functionality. Instead it visualises the instrumentation present in tokio, which is something of a different use case, and not really a traditional debugger. |
Thank you this runtime dump does look useful! If it's fast enough perhaps there's a way to dump periodically and aggregate into some kind of |
Hmm so had some time to experiment with
This all feels like trying to reinvent the wheel:( |
I think that to sample your application, the task dumps are also not the right tool. Right now, there is not so much that works "out of the box" to profile your async Rust application. The best possibility would be to instrument your own application with |
I've tried to go down the Edit: sorry this is an offtopic rant, not related to the draft |
Thanks for the edit. This is the point where I say that we're open to contributions. (-; In all seriousness, I've got some ideas for how it would be at least possible to get child span timings for each task, so while you'd have to instrument functions and futures yourself, you'd at least get a visualization for it in tokio-console. But it's going to take some time to implement, and all work on tokio-console is done by contributors in their spare time, so these things don't move so fast. |
What problem are you trying to solve?
What is my program busy doing right now? For synchronous applications, this question can be answered by capturing stack traces from the running program. For asynchronous applications, this approach is unsatisfactory, since tasks that are idle — waiting to be rescheduled — will not appear.
How should the problem be solved?
Tokio Console could answer this question by displaying the causal tree of
Span
s that stems from each task in the task detail view. The precise user interface would draw inspiration from existing tooling for displaying process trees and span trees. At minimum, the UI should display an htop-like tree view ofSpan
names, targets, and locations. My primary goal with this issue to is to settle on an implementation strategy.Presently, the
tracing
-family of crates does not provide any mechanism for querying the consequences of a span. I've implemented this functionality in thetracing-causality
library, which provides a tracingLayer
that extends eachSpan
in aRegistry
with aSet
encoding that span's direct and indirect consequences. ThisLayer
can then be queried bySpan
ID to get the full causal tree of consequences that stemmed from that span, plus a stream supplying subsequent, incremental updates to that causal tree.I propose beginning by modifying the
console-api
crate to define aConsequences
RPC service that permits clients to:Then, in
console-subscriber
:tracing-causality
layerThen,
console
:Unresolved questions:
Consequences
RPC service only providesSpan
IDs. Where should this additional metadata come from?Any alternatives you've considered?
In the above proposal, the
console-subscriber
does the work of keeping just enough metadata around such that causality trees can be requested on-demand for any Span. This responsibility could, instead, fall onconsole
, itself.In this alternative approach,
console-api
would provide a service that streamed most tracing layeron_*
events to clients. (Some of this functionality is already described inconsole-api
, but not yet implemented inconsole-subscriber
.) Theconsole
application would, then, listen to this stream and maintain just enough data to reconstruct causality trees on-demand.We should seriously consider this option, as it:
How would users interact with this feature?
This feature shall be implemented as a component within the task detail view. The precise user interface would draw inspiration from existing tooling for displaying process trees and span trees. At minimum, the UI should display an htop-like tree view of
Span
names, targets, and locations.Would you like to work on this feature?
yes
The text was updated successfully, but these errors were encountered: