From e164f8709caf837e2e5edaef964ff3d28e0d1160 Mon Sep 17 00:00:00 2001 From: Jonathan Schwender Date: Fri, 9 Dec 2022 20:34:24 +0100 Subject: [PATCH 1/2] Fix the description of steal_count `steal_count` falsely claimed to be the number of times tasks where stolen, but was actually the number of tasks stolen. The description is wrong for all versions of tokio since at least the minimum tokio version tokio-metrics currently supports (v1.15). See: https://github.com/tokio-rs/tokio/blob/f64673580dfc649954eb744eb2734f2f118baa47/tokio/src/runtime/queue.rs#L323 --- README.md | 6 +++--- src/runtime.rs | 13 +++++++------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index ec2d68b..991326c 100644 --- a/README.md +++ b/README.md @@ -177,11 +177,11 @@ tokio::spawn(do_work()); - **[`min_noop_count`]** The minimum number of times any worker thread unparked but performed no work before parking again. - **[`total_steal_count`]** - The number of times worker threads stole tasks from another worker thread. + The number of tasks worker threads stole from another worker thread. - **[`max_steal_count`]** - The maximum number of times any worker thread stole tasks from another worker thread. + The maximum number of tasks any worker thread stole from another worker thread. - **[`min_steal_count`]** - The minimum number of times any worker thread stole tasks from another worker thread. + The minimum number of tasks any worker thread stole from another worker thread. - **[`num_remote_schedules`]** The number of tasks scheduled from outside of the runtime. - **[`total_local_schedule_count`]** diff --git a/src/runtime.rs b/src/runtime.rs index 1d4c79c..37b2c28 100644 --- a/src/runtime.rs +++ b/src/runtime.rs @@ -254,10 +254,11 @@ pub struct RuntimeMetrics { /// - [`RuntimeMetrics::max_noop_count`] pub min_noop_count: u64, - /// The number of times worker threads stole tasks from another worker thread. + /// The number of tasks worker threads stole from another worker thread. /// - /// The worker steal count starts increases by one each time the worker has processed its - /// scheduled queue and successfully steals more pending tasks from another worker. + /// The worker steal count starts increases by the amount of stolen tasks each time the worker + /// has processed its scheduled queue and successfully steals more pending tasks from another + /// worker. /// /// This metric only applies to the **multi-threaded** runtime and will always return `0` when /// using the current thread runtime. @@ -297,7 +298,7 @@ pub struct RuntimeMetrics { /// // Spawn a task that bumps the previous task out of the "next /// // scheduled" slot. /// tokio::spawn(async {}); - /// // Blocking receive on the channe. + /// // Blocking receive on the channel. /// rx.recv().unwrap(); /// flush_metrics().await; /// }).await.unwrap(); @@ -321,7 +322,7 @@ pub struct RuntimeMetrics { /// ``` pub total_steal_count: u64, - /// The maximum number of times any worker thread stole tasks from another worker thread. + /// The maximum number of tasks any worker thread stole from another worker thread. /// /// ##### Definition /// This metric is derived from the maximum of [`tokio::runtime::RuntimeMetrics::worker_steal_count`] @@ -332,7 +333,7 @@ pub struct RuntimeMetrics { /// - [`RuntimeMetrics::min_steal_count`] pub max_steal_count: u64, - /// The minimum number of times any worker thread stole tasks from another worker thread. + /// The minimum number of tasks any worker thread stole from another worker thread. /// /// ##### Definition /// This metric is derived from the minimum of [`tokio::runtime::RuntimeMetrics::worker_steal_count`] From 72d632fcb91887acc0c47e77e8ac45276c63be4b Mon Sep 17 00:00:00 2001 From: Jonathan Schwender Date: Fri, 27 Jan 2023 20:54:52 +0100 Subject: [PATCH 2/2] chore: fix clippy failure --- src/task.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/task.rs b/src/task.rs index 0e64266..d22d200 100644 --- a/src/task.rs +++ b/src/task.rs @@ -2431,7 +2431,7 @@ impl ArcWake for State { #[inline(always)] fn to_nanos(d: Duration) -> u64 { debug_assert!(d <= Duration::from_nanos(u64::MAX)); - (d.as_secs() as u64) + d.as_secs() .wrapping_mul(1_000_000_000) .wrapping_add(d.subsec_nanos() as u64) }