Expand description
Unified buffer manager for memory management.
This module provides centralized memory management across all subsystems with pressure-aware allocation, eviction, and spilling support.
§Architecture
┌────────────────────────────────────────────────────────────┐
│ BufferManager │
│ ┌──────────────┬──────────────┬──────────────┬──────────┐ │
│ │ GraphStorage │ IndexBuffers │ Execution │ Spill │ │
│ │ │ │ Buffers │ Staging │ │
│ └──────────────┴──────────────┴──────────────┴──────────┘ │
│ │ │
│ Pressure Thresholds: │ │
│ < 70% Normal │ │
│ 70-85% Moderate (evict cold) │
│ 85-95% High (aggressive evict/spill) │
│ > 95% Critical (block allocations) │
└────────────────────────────────────────────────────────────┘§Usage
ⓘ
use graphos_common::memory::buffer::{BufferManager, MemoryRegion};
// Create with default config (75% of system RAM)
let manager = BufferManager::with_defaults();
// Or with specific budget
let manager = BufferManager::with_budget(1024 * 1024 * 100); // 100MB
// Allocate memory
if let Some(grant) = manager.try_allocate(1024, MemoryRegion::ExecutionBuffers) {
// Use the memory...
// Memory is automatically released when grant is dropped
}
// Check pressure level
let level = manager.pressure_level();
if level.should_spill() {
// Trigger spilling for spillable operators
}Modules§
- priorities
- Standard priority levels for common consumer types.
Structs§
- Buffer
Manager - The central unified buffer manager.
- Buffer
Manager Config - Configuration for the buffer manager.
- Buffer
Stats - Statistics about buffer manager state.
- Composite
Grant - A collection of memory grants that can be managed together.
- Consumer
Stats - Statistics about a memory consumer.
- Memory
Grant - RAII wrapper for memory allocations.
Enums§
- Memory
Region - Memory region identifiers for budget partitioning.
- Pressure
Level - Memory pressure level thresholds.
- Spill
Error - Error type for spilling operations.
Traits§
- Grant
Releaser - Trait for releasing memory grants.
- Memory
Consumer - Trait for subsystems that consume managed memory.