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: f64Upper fill-ratio that triggers a grow. Default 0.85.
shrink_at: f64Lower fill-ratio that triggers a shrink. Default 0.10.
min_capacity: usizeMinimum allowed capacity (pow2 >= 2). Default 64.
max_capacity: usizeMaximum allowed capacity (pow2). Default 65536.
hysteresis: DurationCooldown after each morph. Default 100 ms.
Trait Implementations§
Source§impl CapacityPolicy for DefaultCapacityPolicy
impl CapacityPolicy for DefaultCapacityPolicy
Source§fn predict(&self, obs: &CapacityPolicyObservation) -> Option<usize>
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.