pub struct AsyncPoolMetrics<'a> { /* private fields */ }
Expand description
Metrics for the asynchronous pool.
Implementations§
Source§impl AsyncPoolMetrics<'_>
impl AsyncPoolMetrics<'_>
Sourcepub fn queue_size(&self) -> u64
pub fn queue_size(&self) -> u64
Returns the amount of tasks in the pool’s queue.
Sourcepub fn finished_tasks(&self) -> u64
pub fn finished_tasks(&self) -> u64
Returns the total number of finished tasks since the last poll.
Sourcepub fn cpu_utilization(&self) -> u8
pub fn cpu_utilization(&self) -> u8
Returns the utilization metric for the pool.
The cpu utilization is measured as the amount of busy work performed by each thread when polling the futures.
A cpu utilization of 100% indicates that the pool has been doing CPU-bound work for the duration of the measurement. A cpu utilization of 0% indicates that the pool didn’t do any CPU-bound work for the duration of the measurement.
Note that this metric is collected and updated for each thread when the main future is polled, thus if no work is being done, it will not be updated.
Sourcepub fn total_utilization(&self) -> u8
pub fn total_utilization(&self) -> u8
Returns the overall utilization of the pool.
This metric provides a high-level view of how busy the pool is, combining both CPU-bound and I/O-bound workloads into a single value. It is intended as a general signal of system load and should be preferred when making scaling decisions.
Unlike Self::cpu_utilization
or Self::activity
, which reflect specific aspects of pool usage,
this method captures the maximum pressure observed in either dimension. This makes it more robust
in edge cases such as:
- High activity with low CPU utilization (e.g., I/O-bound workloads with many tasks waiting).
- Low activity with high CPU utilization (e.g., a few threads performing heavy computation).
Sourcepub fn activity(&self) -> u8
pub fn activity(&self) -> u8
Returns the activity metric for the pool.
The activity is measure as the amount of active tasks in the pool versus the maximum amount of tasks that the pool can have active at the same time.
An activity of 100% indicates that the pool is driving the maximum number of tasks that it can. An activity of 0% indicates that the pool is not driving any tasks.