pub struct BufferManager { /* private fields */ }Expand description
The central unified buffer manager.
Manages memory allocation across all subsystems with pressure-aware eviction and optional spilling support.
Implementations§
Source§impl BufferManager
impl BufferManager
Sourcepub fn new(config: BufferManagerConfig) -> Arc<Self>
pub fn new(config: BufferManagerConfig) -> Arc<Self>
Creates a new buffer manager with the given configuration.
Sourcepub fn with_defaults() -> Arc<Self>
pub fn with_defaults() -> Arc<Self>
Creates a buffer manager with default configuration.
Sourcepub fn with_budget(budget: usize) -> Arc<Self>
pub fn with_budget(budget: usize) -> Arc<Self>
Creates a buffer manager with a specific budget.
Sourcepub fn try_allocate(
self: &Arc<Self>,
size: usize,
region: MemoryRegion,
) -> Option<MemoryGrant>
pub fn try_allocate( self: &Arc<Self>, size: usize, region: MemoryRegion, ) -> Option<MemoryGrant>
Attempts to allocate memory for the given region.
Returns None if allocation would exceed the hard limit after
eviction attempts.
Sourcepub fn pressure_level(&self) -> PressureLevel
pub fn pressure_level(&self) -> PressureLevel
Returns the current pressure level.
Sourcepub fn stats(&self) -> BufferStats
pub fn stats(&self) -> BufferStats
Returns current buffer statistics.
Sourcepub fn register_consumer(&self, consumer: Arc<dyn MemoryConsumer>)
pub fn register_consumer(&self, consumer: Arc<dyn MemoryConsumer>)
Registers a memory consumer for eviction callbacks.
Sourcepub fn unregister_consumer(&self, name: &str)
pub fn unregister_consumer(&self, name: &str)
Unregisters a memory consumer by name.
Sourcepub fn evict_to_target(&self, target_bytes: usize) -> usize
pub fn evict_to_target(&self, target_bytes: usize) -> usize
Forces eviction to reach the target usage.
Returns the number of bytes actually freed.
Sourcepub fn spill_all(&self) -> usize
pub fn spill_all(&self) -> usize
Spills all consumers that support it, regardless of memory pressure.
Used when TierOverride::ForceDisk is configured. Returns total bytes freed.
Sourcepub fn config(&self) -> &BufferManagerConfig
pub fn config(&self) -> &BufferManagerConfig
Returns the configuration.