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

Expose task ID in task dumps #6313

Closed
jswrenn opened this issue Jan 30, 2024 · 2 comments · Fixed by #6328
Closed

Expose task ID in task dumps #6313

jswrenn opened this issue Jan 30, 2024 · 2 comments · Fixed by #6328
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. M-taskdump --cfg tokio_taskdump

Comments

@jswrenn
Copy link
Contributor

jswrenn commented Jan 30, 2024

Is your feature request related to a problem? Please describe.
There is presently no mechanism for following the state of a task between successive dumps.

Describe the solution you'd like
Task dumps should include task IDs. It is probably permissible for these IDs to be occasionally recycled.

@jswrenn jswrenn added A-tokio Area: The main tokio crate C-feature-request Category: A feature request. M-taskdump --cfg tokio_taskdump labels Jan 30, 2024
@jswrenn
Copy link
Contributor Author

jswrenn commented Jan 30, 2024

@Darksonn I see that Tokio already has something called task_id in Core:

pub(super) struct Core<T: Future, S> {
/// Scheduler used to drive this future.
pub(super) scheduler: S,
/// The task's ID, used for populating `JoinError`s.
pub(super) task_id: Id,
/// Either the future or the output.
pub(super) stage: CoreStage<T>,
}

...but I can't immediately follow how to go from a &Task to task_id.

@Darksonn
Copy link
Contributor

See:

/// Returns a [task ID] that uniquely identifies this task relative to other
/// currently spawned tasks.
///
/// **Note**: This is an [unstable API][unstable]. The public API of this type
/// may break in 1.x releases. See [the documentation on unstable
/// features][unstable] for details.
///
/// [task ID]: crate::task::Id
/// [unstable]: crate#unstable-features
#[cfg(tokio_unstable)]
#[cfg_attr(docsrs, doc(cfg(tokio_unstable)))]
pub fn id(&self) -> super::Id {
// Safety: The header pointer is valid.
unsafe { Header::get_id(self.raw.header_ptr()) }
}

jswrenn added a commit to jswrenn/tokio that referenced this issue Feb 5, 2024
Task `Id`s provide a semi-stable identifier for monitoring task
state across task dumps.

Fixes tokio-rs#6313
Darksonn pushed a commit that referenced this issue Feb 5, 2024
Task `Id`s provide a semi-stable identifier for monitoring task
state across task dumps.

Fixes #6313
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. M-taskdump --cfg tokio_taskdump
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants