CleanupConfig

Struct CleanupConfig 

Source
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: Duration

Base cleanup interval (when utilization is moderate).

§min_interval: Duration

Minimum cleanup interval (under high utilization).

§max_interval: Duration

Maximum cleanup interval (under low utilization).

§high_utilization_threshold: f64

Cache utilization threshold for aggressive cleanup (0.0-1.0).

§low_utilization_threshold: f64

Cache utilization threshold for relaxed cleanup (0.0-1.0).

§utilization_hysteresis: f64

Hysteresis for utilization thresholds (prevents flapping). Applied as ± adjustment to thresholds when already in a state.

§drop_some_threshold: f64

Utilization threshold for DropSome backpressure (0.0-1.0). Default: 0.93

§drop_most_threshold: f64

Utilization threshold for DropMost backpressure (0.0-1.0). Default: 0.96

§block_new_threshold: f64

Utilization threshold for BlockNew backpressure (0.0-1.0). Default: 0.98

§target_cleanup_duration: Duration

Target cleanup duration (try to keep cleanup under this).

§high_load_message_rate: f64

Message rate threshold for high load (messages per second).

§rate_window: Duration

Window size for calculating message rate.

§batch_size_smoothing: f64

Batch size smoothing factor (0.0-1.0). Higher = more responsive to changes. Recommended: 0.1-0.2 for production stability.

§ttl_divisor: f64

Cleanup 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: f64

Weight 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: f64

Smoothing factor for efficiency EMA (0.0-1.0). Lower = smoother/slower to respond, higher = more responsive.

§min_cycles_for_efficiency: u64

Minimum cleanup cycles before efficiency data is trusted. Prevents wild adjustments during startup.

§max_ttl_interval_factor: f64

Maximum 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

Source

pub fn new() -> Self

Create a new cleanup config with default values.

Source

pub fn high_throughput() -> Self

Configuration for high-throughput scenarios.

More aggressive cleanup to prevent memory pressure.

Source

pub fn low_latency() -> Self

Configuration for low-latency scenarios.

Smaller, more frequent cleanups to minimize impact.

Source

pub const fn with_base_interval(self, interval: Duration) -> Self

Set the base cleanup interval (builder pattern).

Source

pub const fn with_min_interval(self, interval: Duration) -> Self

Set the minimum cleanup interval (builder pattern).

Source

pub const fn with_max_interval(self, interval: Duration) -> Self

Set the maximum cleanup interval (builder pattern).

Source

pub fn with_high_utilization_threshold(self, threshold: f64) -> Self

Set the high utilization threshold (builder pattern).

Source

pub fn with_low_utilization_threshold(self, threshold: f64) -> Self

Set the low utilization threshold (builder pattern).

Source

pub fn with_ttl_divisor(self, divisor: f64) -> Self

Set the TTL divisor (builder pattern).

Source

pub fn with_backpressure_thresholds( self, drop_some: f64, drop_most: f64, block_new: f64, ) -> Self

Set backpressure thresholds (builder pattern).

Source

pub fn with_efficiency_smoothing(self, smoothing: f64) -> Self

Set efficiency smoothing factor (builder pattern).

Trait Implementations§

Source§

impl Clone for CleanupConfig

Source§

fn clone(&self) -> CleanupConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for CleanupConfig

Source§

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

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

impl Default for CleanupConfig

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more