pub struct AdaptiveMemtableSizer { /* private fields */ }Expand description
Adaptive memtable sizer with memory pressure feedback
Dynamically adjusts memtable flush threshold based on:
- Write rate (to maintain target buffer duration)
- Memory pressure (to avoid OOM)
Implementations§
Source§impl AdaptiveMemtableSizer
impl AdaptiveMemtableSizer
Sourcepub fn with_config(config: AdaptiveMemtableConfig) -> Self
pub fn with_config(config: AdaptiveMemtableConfig) -> Self
Create with custom configuration
Sourcepub fn record_write(&self, bytes: usize)
pub fn record_write(&self, bytes: usize)
Record bytes written (call on every write)
Sourcepub fn current_size(&self) -> usize
pub fn current_size(&self) -> usize
Get current recommended memtable size
Sourcepub fn write_rate(&self) -> f64
pub fn write_rate(&self) -> f64
Get estimated write rate in bytes per second
Sourcepub fn memory_pressure(&self) -> f64
pub fn memory_pressure(&self) -> f64
Get current memory pressure (0.0 - 1.0)
Sourcepub fn update(&self) -> usize
pub fn update(&self) -> usize
Update the adaptive size (call periodically, e.g., every second)
Returns the new recommended memtable size
Sourcepub fn should_flush(&self, current_memtable_bytes: u64) -> bool
pub fn should_flush(&self, current_memtable_bytes: u64) -> bool
Check if the memtable should be flushed based on current size
Sourcepub fn stats(&self) -> AdaptiveMemtableStats
pub fn stats(&self) -> AdaptiveMemtableStats
Get statistics for monitoring
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for AdaptiveMemtableSizer
impl RefUnwindSafe for AdaptiveMemtableSizer
impl Send for AdaptiveMemtableSizer
impl Sync for AdaptiveMemtableSizer
impl Unpin for AdaptiveMemtableSizer
impl UnsafeUnpin for AdaptiveMemtableSizer
impl UnwindSafe for AdaptiveMemtableSizer
Blanket Implementations§
impl<T> Allocation for T
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>
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 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>
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