Skip to main content

InstanceStats

Struct InstanceStats 

Source
pub struct InstanceStats {
    pub ops_observed: u64,
    pub total_latency_ticks: u64,
    pub contention_ops: u64,
    pub op_kind_counts: [u64; 8],
    pub last_seen_us_ago: u64,
    pub migrations_triggered: u64,
    pub per_op_kind_distinct_threads: [[u32; 4]; 8],
    pub per_op_kind_distinct_count: [u8; 8],
}
Expand description

Aggregated statistics for one registered instance.

Updated by the sidecar each poll cycle from drained observations.

Fields§

§ops_observed: u64§total_latency_ticks: u64§contention_ops: u64§op_kind_counts: [u64; 8]

Per-op-kind counts. Index by Observation.op_kind (clamped to the valid range). Primitives that adapt based on a ratio of op kinds (e.g., reads vs writes) consume these.

§last_seen_us_ago: u64§migrations_triggered: u64

Number of migrations the sidecar has triggered on this instance (apply_migration calls that resulted in a tag change). Used by bench harnesses to measure adaptation-latency convergence.

§per_op_kind_distinct_threads: [[u32; 4]; 8]

Per-op-kind distinct-thread-id cache. Filled lazily by the drain as observations arrive. Once a slot fills with a tid that doesn’t match any earlier slot, the corresponding count in per_op_kind_distinct_count increments.

§per_op_kind_distinct_count: [u8; 8]

Distinct thread count observed per op_kind (saturates at MAX_TRACKED_THREADS_PER_KIND + 1 - meaning “more than the slot table can hold”). >= 2 is the typical multi-producer or multi-consumer detection threshold for primitive policies.

Implementations§

Source§

impl InstanceStats

Source

pub fn average_latency_ticks(&self) -> u64

Source

pub fn contention_rate(&self) -> f64

Source

pub fn op_kind_total(&self) -> u64

Total ops observed across all op kinds. Equals ops_observed for primitives that always set a non-zero op_kind on their observations.

Source

pub fn ratio_of(&self, kind: u16, total_kinds: &[u16]) -> f64

Ratio of one op kind to the total of two op kinds. Returns 0.0 when both counts are zero (avoids divide-by-zero in policies).

Source

pub fn distinct_threads_for(&self, kind: u16) -> u8

Distinct producer-thread count observed for one op kind.

>= 2 indicates true multi-producer (or multi-consumer for the recv-side op kind) usage on this primitive - the right signal for a ChannelPolicy promoting SPSC → MPMC, an AdaptiveCell noticing multi-writer churn, etc. Saturates at MAX_TRACKED_THREADS_PER_KIND + 1.

Source

pub fn is_multi_thread_for(&self, kind: u16) -> bool

True when the given op kind has been observed from more than one distinct producer thread.

Trait Implementations§

Source§

impl Clone for InstanceStats

Source§

fn clone(&self) -> InstanceStats

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for InstanceStats

Source§

impl Debug for InstanceStats

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for InstanceStats

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.