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 blocking_queue_depth #49

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ tokio::spawn(do_work());
The maximum number of tasks currently scheduled any worker's local queue.
- **[`min_local_queue_depth`]**
The minimum number of tasks currently scheduled any worker's local queue.
- **[`blocking_queue_depth`]**
The number of tasks currently waiting to be executed in the blocking threadpool.
- **[`elapsed`]**
Total amount of time elapsed since observing runtime metrics.
- **[`budget_forced_yield_count`]**
Expand Down
10 changes: 9 additions & 1 deletion src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,12 @@ pub struct RuntimeMetrics {
/// - [`RuntimeMetrics::max_local_queue_depth`]
pub min_local_queue_depth: usize,

/// The number of tasks currently waiting to be executed in the runtime's blocking threadpool.
///
/// ##### Definition
/// This metric is derived from [`tokio::runtime::RuntimeMetrics::blocking_queue_depth`].
pub blocking_queue_depth: usize,

/// Total amount of time elapsed since observing runtime metrics.
pub elapsed: Duration,

Expand Down Expand Up @@ -1273,7 +1279,6 @@ impl Worker {
);

// Local scheduled tasks is an absolute value

let local_scheduled_tasks = rt.worker_local_queue_depth(self.worker);
metrics.total_local_queue_depth += local_scheduled_tasks;

Expand All @@ -1284,6 +1289,9 @@ impl Worker {
if local_scheduled_tasks < metrics.min_local_queue_depth {
metrics.min_local_queue_depth = local_scheduled_tasks;
}

// Blocking queue depth is an absolute value too
metrics.blocking_queue_depth = rt.blocking_queue_depth();
}
}

Expand Down
Loading