Skip to content

Conversation

@jsdt
Copy link
Contributor

@jsdt jsdt commented Apr 1, 2025

Description of Changes

Adding some tokio runtime stats. Metrics like tokio_num_alive_tasks and tokio_global_queue_depth could be useful to see if tokio is falling behind. Tokio metrics are described here.

There are some other per-worker stats that could be useful to add in the future if we are having issues with tokio scheduling.

Many of the metrics require using the tokio_unstable compilation flag, which is awkward to enable. The code will still compile if tokio_unstable is not enabled, though it will have some unused variable warnings.

API and ABI breaking changes

If this is an API or ABI breaking change, please apply the
corresponding GitHub label.

Expected complexity level and risk

Testing

Tested by looking at metrics locally.

@jsdt jsdt requested a review from Copilot April 1, 2025 23:18
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds several new metrics to monitor the Tokio runtime, providing insights into worker utilization and task scheduling.

  • Added new metric definitions for various Tokio runtime parameters (worker count, blocking threads, task counts, and queue depths).
  • Implemented the spawn_tokio_stats function to collect and update these metrics periodically.
  • Updated the Cargo configuration to enable the tokio_unstable flag required for these metrics.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
crates/core/src/worker_metrics/mod.rs Introduces new Tokio runtime metrics and the stats collection task
.cargo/config.toml Configures the build to use the tokio_unstable flag

@jsdt jsdt requested a review from Centril April 2, 2025 19:28
@jsdt jsdt added this pull request to the merge queue Apr 3, 2025
Merged via the queue into master with commit 396d1c2 Apr 3, 2025
14 of 15 checks passed
@jsdt jsdt deleted the jsdt/tokio-metrics branch April 3, 2025 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants