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

rt: add io_driver_ready_count metric #40

Merged
merged 1 commit into from
Mar 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ rt = ["tokio"]
tokio-stream = "0.1.11"
futures-util = "0.3.19"
pin-project-lite = "0.2.7"
tokio = { version = "1.26.0", features = ["rt", "stats", "time"], optional = true }
tokio = { version = "1.26.0", features = ["rt", "stats", "time", "net"], optional = true }

[dev-dependencies]
axum = "0.6"
Expand Down
11 changes: 11 additions & 0 deletions src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,12 @@ pub struct RuntimeMetrics {
/// ##### Definition
/// This metric is derived from [`tokio::runtime::RuntimeMetrics::budget_forced_yield_count`].
pub budget_forced_yield_count: u64,

/// Returns the number of ready events processed by the runtime’s I/O driver.
///
/// ##### Definition
/// This metric is derived from [`tokio::runtime::RuntimeMetrics::io_driver_ready_count`].
pub io_driver_ready_count: u64,
}

/// Snapshot of per-worker metrics
Expand Down Expand Up @@ -971,6 +977,7 @@ pub struct RuntimeIntervals {
// Number of tasks scheduled from *outside* of the runtime
num_remote_schedules: u64,
budget_forced_yield_count: u64,
io_driver_ready_count: u64,
}

impl RuntimeIntervals {
Expand All @@ -979,6 +986,7 @@ impl RuntimeIntervals {

let num_remote_schedules = self.runtime.remote_schedule_count();
let budget_forced_yields = self.runtime.budget_forced_yield_count();
let io_driver_ready_events = self.runtime.io_driver_ready_count();

let mut metrics = RuntimeMetrics {
workers_count: self.runtime.num_workers(),
Expand All @@ -994,12 +1002,14 @@ impl RuntimeIntervals {
min_busy_duration: Duration::from_secs(1000000000),
min_local_queue_depth: usize::MAX,
budget_forced_yield_count: budget_forced_yields - self.budget_forced_yield_count,
io_driver_ready_count: io_driver_ready_events - self.io_driver_ready_count,
..Default::default()
};

self.num_remote_schedules = num_remote_schedules;
self.started_at = now;
self.budget_forced_yield_count = budget_forced_yields;
self.io_driver_ready_count = io_driver_ready_events;

for worker in &mut self.workers {
worker.probe(&self.runtime, &mut metrics);
Expand Down Expand Up @@ -1084,6 +1094,7 @@ impl RuntimeMonitor {
workers,
num_remote_schedules: self.runtime.remote_schedule_count(),
budget_forced_yield_count: self.runtime.budget_forced_yield_count(),
io_driver_ready_count: self.runtime.io_driver_ready_count(),
}
}
}
Expand Down