pub struct SpilloverManager { /* private fields */ }Expand description
Async spillover manager for write buffers
§Problem Addressed
Current WriteBufferManager blocks writes when hard limit is exceeded. This causes latency spikes for foreground operations.
§Solution
Add async spillover to secondary storage (disk) before blocking:
- When soft limit exceeded → trigger async flush to SSTable
- When 90% limit exceeded → trigger spillover to temp file
- Only block at 100% when spillover buffer is also full
§Architecture
Memtable (hot data)
│
├── Soft limit (80%) → Async SSTable flush
│
├── Spillover limit (90%) → Async temp file write
│
└── Hard limit (100%) → Block (last resort)
Spillover files are replayed into new SSTables during quiet periods.Implementations§
Source§impl SpilloverManager
impl SpilloverManager
Sourcepub fn new(
write_buffer: Arc<WriteBufferManager>,
spillover_capacity: u64,
) -> (Self, Receiver<SpilloverRequest>)
pub fn new( write_buffer: Arc<WriteBufferManager>, spillover_capacity: u64, ) -> (Self, Receiver<SpilloverRequest>)
Create a new spillover manager
Sourcepub fn should_spillover(&self) -> bool
pub fn should_spillover(&self) -> bool
Check if spillover should be triggered
Sourcepub fn is_spillover_full(&self) -> bool
pub fn is_spillover_full(&self) -> bool
Check if spillover buffer is full
Sourcepub fn reserve_memory(
&self,
bytes: u64,
data: Vec<(Vec<u8>, Vec<u8>)>,
) -> Result<bool, SpilloverRequest>
pub fn reserve_memory( &self, bytes: u64, data: Vec<(Vec<u8>, Vec<u8>)>, ) -> Result<bool, SpilloverRequest>
Reserve memory with spillover fallback
Returns:
Ok(false)- Memory reserved, no action neededOk(true)- Memory reserved, flush should be triggeredErr(SpilloverRequest)- Caller should spill this data before proceeding
Sourcepub fn release_spillover(&self, bytes: u64)
pub fn release_spillover(&self, bytes: u64)
Release spillover capacity after recovery
Sourcepub fn is_spillover_active(&self) -> bool
pub fn is_spillover_active(&self) -> bool
Check if spillover is active
Sourcepub fn spillover_usage(&self) -> u64
pub fn spillover_usage(&self) -> u64
Get spillover usage
Sourcepub fn spillover_capacity(&self) -> u64
pub fn spillover_capacity(&self) -> u64
Get spillover capacity
Sourcepub fn stats(&self) -> &SpilloverStats
pub fn stats(&self) -> &SpilloverStats
Get statistics
Auto Trait Implementations§
impl !Freeze for SpilloverManager
impl !RefUnwindSafe for SpilloverManager
impl !UnwindSafe for SpilloverManager
impl Send for SpilloverManager
impl Sync for SpilloverManager
impl Unpin for SpilloverManager
impl UnsafeUnpin for SpilloverManager
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
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