Skip to main content

DefaultCapacityPolicy

Struct DefaultCapacityPolicy 

Source
pub struct DefaultCapacityPolicy {
    pub grow_at: f64,
    pub shrink_at: f64,
    pub min_capacity: usize,
    pub max_capacity: usize,
    pub hysteresis: Duration,
}
Expand description

Default capacity policy: fill-ratio with hysteresis.

On every scan the sidecar computes fill_ratio = approx_len / total_capacity. If fill_ratio >= grow_at, the policy doubles the capacity (up to max_capacity). If fill_ratio <= shrink_at, the policy halves the capacity (down to min_capacity). Otherwise it returns None.

Suppressed for since_last_morph < hysteresis to prevent thrashing under bursty load. Default hysteresis 100 ms matches the shape-morph policy.

Fields§

§grow_at: f64

Upper fill-ratio that triggers a grow. Default 0.85.

§shrink_at: f64

Lower fill-ratio that triggers a shrink. Default 0.10.

§min_capacity: usize

Minimum allowed capacity (pow2 >= 2). Default 64.

§max_capacity: usize

Maximum allowed capacity (pow2). Default 65536.

§hysteresis: Duration

Cooldown after each morph. Default 100 ms.

Trait Implementations§

Source§

impl CapacityPolicy for DefaultCapacityPolicy

Source§

fn predict(&self, obs: &CapacityPolicyObservation) -> Option<usize>

Predicts the doubled capacity once the fill ratio crosses 75% of the grow threshold, and the halved capacity once it falls under 150% of the shrink threshold - the trend bands in front of the decide thresholds. Deliberately NOT gated on hysteresis: the cooldown window after a morph is exactly the right time to build the next predicted backing.

Source§

fn decide(&self, obs: &CapacityPolicyObservation) -> Option<usize>

Source§

impl Default for DefaultCapacityPolicy

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> 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, 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.