Skip to content
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

First class notion of runtimes #130

Open
hawkw opened this issue Sep 10, 2021 · 3 comments
Open

First class notion of runtimes #130

hawkw opened this issue Sep 10, 2021 · 3 comments
Labels
A-instrumentation Area: instrumentation. A-recording Area: recording. C-api Crate: console-api C-console Crate: console. C-subscriber Crate: console-subscriber. S-feature Severity: feature. This is adding a new feature.

Comments

@hawkw
Copy link
Member

hawkw commented Sep 10, 2021

A Tokio application is capable of having multiple independent runtimes. I believe this may be the case for other runtime implementations as well (e.g., I believe rayon allows creating multiple separate threadpools). This may also be useful when a crate uses multiple async runtimes provided by different libraries (e.g. running async-stds global runtime in a bg thread).

Currently, the console has no way of being aware of this --- we just see a lot of tasks, without any way of determining which runtime a task is running on. It would be nice to be able to tag tasks with runtimes. In the future, when we add runtime-global stats/metrics, we will also want a way to uniquely identify runtimes.

As a first pass, we could consider adding a field to the task spans in Tokio with some kind of runtime ID (could just increment an integer every time Runtime::new is called), and add that to the task spans when spawning. This would at least let users distinguish between runtimes by looking at the task's fields. Tokio could also add a new (unstable) builder method to allow naming the runtime itself, as well as naming its worker threads.

Building on that, we could make the console subscriber actually aware of this field, and allow associating tasks with runtimes. We could consider adding a new RPC to list runtimes and/or get per-runtime stats.

@hawkw hawkw added A-instrumentation Area: instrumentation. A-recording Area: recording. C-console Crate: console. C-subscriber Crate: console-subscriber. S-feature Severity: feature. This is adding a new feature. labels Sep 10, 2021
@jplatte
Copy link
Member

jplatte commented Dec 17, 2021

Somewhat related, the task_group crate provides another way of grouping tasks and it would be awesome if that could be visualized as well. (just something that came to mind when reading this issue, I haven't actually attempted to use Console with a project that uses that crate)

@hawkw
Copy link
Member Author

hawkw commented Dec 17, 2021

This is also going to be necessary in order to integrate with Tokio's runtime metrics API (tokio-rs/tokio#4073), cc @LucioFranco.

@hawkw hawkw changed the title Multiple runtimes First class notion of runtimes Dec 17, 2021
@hawkw hawkw added the C-api Crate: console-api label Dec 17, 2021
@hawkw
Copy link
Member Author

hawkw commented Dec 17, 2021

I imagine the wire format changes are going to be something like this:

  • add a "runtime ID" to identify runtimes
  • add a "watch runtimes" RPC that returns a stream of runtime stats updates, and a map of any newly-detected runtimes (similarly to how the tasks RPC works)
  • add (optional) runtime ID fields to tasks, identifying which runtime the task is running on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-instrumentation Area: instrumentation. A-recording Area: recording. C-api Crate: console-api C-console Crate: console. C-subscriber Crate: console-subscriber. S-feature Severity: feature. This is adding a new feature.
Projects
None yet
Development

No branches or pull requests

2 participants