pub struct CleanupConfig {Show 18 fields
pub base_interval: Duration,
pub min_interval: Duration,
pub max_interval: Duration,
pub high_utilization_threshold: f64,
pub low_utilization_threshold: f64,
pub utilization_hysteresis: f64,
pub drop_some_threshold: f64,
pub drop_most_threshold: f64,
pub block_new_threshold: f64,
pub target_cleanup_duration: Duration,
pub high_load_message_rate: f64,
pub rate_window: Duration,
pub batch_size_smoothing: f64,
pub ttl_divisor: f64,
pub efficiency_weight: f64,
pub efficiency_smoothing: f64,
pub min_cycles_for_efficiency: u64,
pub max_ttl_interval_factor: f64,
}Expand description
Configuration for dynamic cleanup tuning.
Fields§
§base_interval: DurationBase cleanup interval (when utilization is moderate).
min_interval: DurationMinimum cleanup interval (under high utilization).
max_interval: DurationMaximum cleanup interval (under low utilization).
high_utilization_threshold: f64Cache utilization threshold for aggressive cleanup (0.0-1.0).
low_utilization_threshold: f64Cache utilization threshold for relaxed cleanup (0.0-1.0).
utilization_hysteresis: f64Hysteresis for utilization thresholds (prevents flapping). Applied as ± adjustment to thresholds when already in a state.
drop_some_threshold: f64Utilization threshold for DropSome backpressure (0.0-1.0). Default: 0.93
drop_most_threshold: f64Utilization threshold for DropMost backpressure (0.0-1.0). Default: 0.96
block_new_threshold: f64Utilization threshold for BlockNew backpressure (0.0-1.0). Default: 0.98
target_cleanup_duration: DurationTarget cleanup duration (try to keep cleanup under this).
high_load_message_rate: f64Message rate threshold for high load (messages per second).
rate_window: DurationWindow size for calculating message rate.
batch_size_smoothing: f64Batch size smoothing factor (0.0-1.0). Higher = more responsive to changes. Recommended: 0.1-0.2 for production stability.
ttl_divisor: f64Cleanup interval should be at least TTL divided by this value. Default is 4, meaning cleanup runs at least 4 times per TTL period. Valid range: 2.0-20.0 (enforced at construction).
efficiency_weight: f64Weight for removal efficiency in batch size calculation (0.0-1.0). Higher values make batch size more responsive to how many entries are actually being removed vs just scanned.
efficiency_smoothing: f64Smoothing factor for efficiency EMA (0.0-1.0). Lower = smoother/slower to respond, higher = more responsive.
min_cycles_for_efficiency: u64Minimum cleanup cycles before efficiency data is trusted. Prevents wild adjustments during startup.
max_ttl_interval_factor: f64Maximum TTL-based interval multiplier to prevent huge intervals. If TTL is very large, interval is capped at max_interval * this factor.
Implementations§
Source§impl CleanupConfig
impl CleanupConfig
Sourcepub fn high_throughput() -> Self
pub fn high_throughput() -> Self
Configuration for high-throughput scenarios.
More aggressive cleanup to prevent memory pressure.
Sourcepub fn low_latency() -> Self
pub fn low_latency() -> Self
Configuration for low-latency scenarios.
Smaller, more frequent cleanups to minimize impact.
Sourcepub const fn with_base_interval(self, interval: Duration) -> Self
pub const fn with_base_interval(self, interval: Duration) -> Self
Set the base cleanup interval (builder pattern).
Sourcepub const fn with_min_interval(self, interval: Duration) -> Self
pub const fn with_min_interval(self, interval: Duration) -> Self
Set the minimum cleanup interval (builder pattern).
Sourcepub const fn with_max_interval(self, interval: Duration) -> Self
pub const fn with_max_interval(self, interval: Duration) -> Self
Set the maximum cleanup interval (builder pattern).
Sourcepub fn with_high_utilization_threshold(self, threshold: f64) -> Self
pub fn with_high_utilization_threshold(self, threshold: f64) -> Self
Set the high utilization threshold (builder pattern).
Sourcepub fn with_low_utilization_threshold(self, threshold: f64) -> Self
pub fn with_low_utilization_threshold(self, threshold: f64) -> Self
Set the low utilization threshold (builder pattern).
Sourcepub fn with_ttl_divisor(self, divisor: f64) -> Self
pub fn with_ttl_divisor(self, divisor: f64) -> Self
Set the TTL divisor (builder pattern).
Sourcepub fn with_backpressure_thresholds(
self,
drop_some: f64,
drop_most: f64,
block_new: f64,
) -> Self
pub fn with_backpressure_thresholds( self, drop_some: f64, drop_most: f64, block_new: f64, ) -> Self
Set backpressure thresholds (builder pattern).
Sourcepub fn with_efficiency_smoothing(self, smoothing: f64) -> Self
pub fn with_efficiency_smoothing(self, smoothing: f64) -> Self
Set efficiency smoothing factor (builder pattern).
Trait Implementations§
Source§impl Clone for CleanupConfig
impl Clone for CleanupConfig
Source§fn clone(&self) -> CleanupConfig
fn clone(&self) -> CleanupConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CleanupConfig
impl Debug for CleanupConfig
Auto Trait Implementations§
impl Freeze for CleanupConfig
impl RefUnwindSafe for CleanupConfig
impl Send for CleanupConfig
impl Sync for CleanupConfig
impl Unpin for CleanupConfig
impl UnwindSafe for CleanupConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
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> ⓘ
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