Struct AsyncPoolMetrics

Source
pub struct AsyncPoolMetrics<'a> { /* private fields */ }
Expand description

Metrics for the asynchronous pool.

Implementations§

Source§

impl AsyncPoolMetrics<'_>

Source

pub fn queue_size(&self) -> u64

Returns the amount of tasks in the pool’s queue.

Source

pub fn finished_tasks(&self) -> u64

Returns the total number of finished tasks since the last poll.

Source

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.

Source

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).
Source

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.

Trait Implementations§

Source§

impl<'a> Debug for AsyncPoolMetrics<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for AsyncPoolMetrics<'a>

§

impl<'a> RefUnwindSafe for AsyncPoolMetrics<'a>

§

impl<'a> Send for AsyncPoolMetrics<'a>

§

impl<'a> Sync for AsyncPoolMetrics<'a>

§

impl<'a> Unpin for AsyncPoolMetrics<'a>

§

impl<'a> UnwindSafe for AsyncPoolMetrics<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T