pub struct ConcurrencyMetrics { /* private fields */ }Expand description
Concurrency metrics for resource manager monitoring
§Educational: Observability-Driven Tuning
These metrics answer key questions:
- “Are we CPU-saturated?” → cpu_saturation_percent()
- “Are we I/O-saturated?” → io_saturation_percent()
- “What’s causing latency?” → wait time histograms
- “How much memory are we using?” → memory_used_bytes
Use these to guide tuning decisions!
Implementations§
Source§impl ConcurrencyMetrics
impl ConcurrencyMetrics
pub fn new(cpu_tokens: usize, io_tokens: usize, memory_capacity: usize) -> Self
Sourcepub fn update_cpu_tokens_available(&self, available: usize)
pub fn update_cpu_tokens_available(&self, available: usize)
Update CPU tokens available (from ResourceManager)
Sourcepub fn cpu_tokens_available(&self) -> usize
pub fn cpu_tokens_available(&self) -> usize
Get CPU tokens available
Sourcepub fn cpu_saturation_percent(&self) -> f64
pub fn cpu_saturation_percent(&self) -> f64
Get CPU saturation percentage
§Educational: What is saturation?
Saturation = (tokens_in_use / total_tokens) × 100
- 0%: Idle, not utilizing resources
- 50%: Good utilization
- 80-90%: High utilization, approaching saturation
- 100%: Fully saturated, tasks waiting
Sourcepub fn record_cpu_wait(&self, duration: Duration)
pub fn record_cpu_wait(&self, duration: Duration)
Record CPU token wait time
Sourcepub fn cpu_wait_p50(&self) -> u64
pub fn cpu_wait_p50(&self) -> u64
Get CPU wait time percentile
pub fn cpu_wait_p95(&self) -> u64
pub fn cpu_wait_p99(&self) -> u64
Sourcepub fn update_io_tokens_available(&self, available: usize)
pub fn update_io_tokens_available(&self, available: usize)
Update I/O tokens available (from ResourceManager)
pub fn io_tokens_available(&self) -> usize
pub fn io_saturation_percent(&self) -> f64
Sourcepub fn record_io_wait(&self, duration: Duration)
pub fn record_io_wait(&self, duration: Duration)
Record I/O token wait time
pub fn io_wait_p50(&self) -> u64
pub fn io_wait_p95(&self) -> u64
pub fn io_wait_p99(&self) -> u64
pub fn update_memory_used(&self, bytes: usize)
pub fn memory_used_bytes(&self) -> usize
pub fn memory_used_mb(&self) -> f64
pub fn memory_capacity_bytes(&self) -> usize
pub fn memory_utilization_percent(&self) -> f64
pub fn worker_started(&self)
pub fn worker_completed(&self)
pub fn active_workers(&self) -> usize
pub fn tasks_spawned(&self) -> u64
pub fn tasks_completed(&self) -> u64
Sourcepub fn update_cpu_queue_depth(&self, depth: usize)
pub fn update_cpu_queue_depth(&self, depth: usize)
Update CPU queue depth
§Educational: Observing Backpressure
Queue depth reveals whether workers can keep up with the reader:
- Depth near 0: Workers are faster than reader (good!)
- Depth near capacity: Workers are bottleneck (increase workers or optimize stages)
- Depth at capacity: Reader is blocked (severe backpressure)
Sourcepub fn cpu_queue_depth(&self) -> usize
pub fn cpu_queue_depth(&self) -> usize
Get current CPU queue depth
Sourcepub fn cpu_queue_depth_max(&self) -> usize
pub fn cpu_queue_depth_max(&self) -> usize
Get maximum CPU queue depth observed
Sourcepub fn record_cpu_queue_wait(&self, duration: Duration)
pub fn record_cpu_queue_wait(&self, duration: Duration)
Record time a chunk waited in CPU queue
Sourcepub fn cpu_queue_wait_p50(&self) -> u64
pub fn cpu_queue_wait_p50(&self) -> u64
Get P50 (median) CPU queue wait time in milliseconds
Sourcepub fn cpu_queue_wait_p95(&self) -> u64
pub fn cpu_queue_wait_p95(&self) -> u64
Get P95 CPU queue wait time in milliseconds
Sourcepub fn cpu_queue_wait_p99(&self) -> u64
pub fn cpu_queue_wait_p99(&self) -> u64
Get P99 CPU queue wait time in milliseconds
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ConcurrencyMetrics
impl RefUnwindSafe for ConcurrencyMetrics
impl Send for ConcurrencyMetrics
impl Sync for ConcurrencyMetrics
impl Unpin for ConcurrencyMetrics
impl UnwindSafe for ConcurrencyMetrics
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more