Skip to main content

async_runtime/
stats.rs

1//! Optional runtime scheduling statistics.
2
3/// A point-in-time snapshot of runtime scheduler counters.
4///
5/// The values are approximate under concurrent activity. Queue counts describe
6/// runnable tasks that have not yet been taken by a worker; they are not a
7/// task-liveness or completion count.
8#[cfg(feature = "stats")]
9#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
10pub struct RuntimeStats {
11    /// Runnable high-priority tasks currently queued.
12    pub queued_high: usize,
13    /// Runnable normal-priority tasks currently queued.
14    pub queued_normal: usize,
15    /// Runnable background-priority tasks currently queued.
16    pub queued_background: usize,
17    /// Number of worker threads owned by the runtime.
18    pub workers: usize,
19    /// Workers currently parked waiting for more work.
20    pub sleeping_workers: usize,
21    /// Runnables taken by workers for execution.
22    pub executed: u64,
23    /// Successful steals from another worker's local queue.
24    ///
25    /// This counts successful steal operations, which may transfer a batch of
26    /// runnable tasks into the stealing worker's local queue.
27    pub stolen: u64,
28    /// Attempts to steal from another worker's local queue.
29    pub steal_attempts: u64,
30    /// Tasks submitted from outside a runtime worker.
31    pub external_spawned: u64,
32    /// Tasks submitted from the owning runtime's worker threads.
33    pub local_spawned: u64,
34    /// Times workers entered the parked state.
35    pub parks: u64,
36    /// Worker wake notifications delivered for new work or shutdown.
37    pub wakes: u64,
38}