Skip to main content

Module buffer

Module buffer 

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

BufferManager
The central unified buffer manager.
BufferManagerConfig
Configuration for the buffer manager.
BufferStats
Statistics about buffer manager state.
CompositeGrant
A collection of memory grants that can be managed together.
ConsumerStats
Statistics about a memory consumer.
MemoryGrant
RAII wrapper for memory allocations.

Enums§

MemoryRegion
Memory region identifiers for budget partitioning.
PressureLevel
Memory pressure level thresholds.
SpillError
Error type for spilling operations.

Traits§

GrantReleaser
Trait for releasing memory grants.
MemoryConsumer
Trait for subsystems that consume managed memory.