pub struct OverflowRegion { /* private fields */ }Expand description
mmap-backed overflow region owned by a single core.
Uses a bump allocator within the mmap’d file with a free-list for slot reuse. When a slot is freed, it’s added to the free-list so future writes of equal or smaller size can reclaim the space without advancing the bump cursor.
Not Send or Sync — it’s single-thread owned.
Implementations§
Source§impl OverflowRegion
impl OverflowRegion
Sourcepub const DEFAULT_INITIAL_CAPACITY: usize
pub const DEFAULT_INITIAL_CAPACITY: usize
Default initial mmap size.
Corresponds to MemoryTuning::overflow_initial_bytes.
Sourcepub const DEFAULT_MAX_CAPACITY: usize
pub const DEFAULT_MAX_CAPACITY: usize
Default maximum capacity (prevents unbounded growth).
Corresponds to MemoryTuning::overflow_max_bytes.
Sourcepub fn open(path: &Path) -> Result<Self>
pub fn open(path: &Path) -> Result<Self>
Open or create an overflow region at the given path.
If the file doesn’t exist, it’s created with the initial capacity. If the file exists, it’s mapped at current size.
Sourcepub fn open_with_config(
path: &Path,
initial_capacity: usize,
max_capacity: usize,
) -> Result<Self>
pub fn open_with_config( path: &Path, initial_capacity: usize, max_capacity: usize, ) -> Result<Self>
Open or create an overflow region with explicit initial and maximum capacity.
Use this when applying runtime config from MemoryTuning.
Sourcepub fn open_with_capacity(path: &Path, initial_capacity: usize) -> Result<Self>
pub fn open_with_capacity(path: &Path, initial_capacity: usize) -> Result<Self>
Open or create an overflow region with a specific initial capacity.
Sourcepub fn write(&mut self, data: &[u8], engine: EngineId) -> Result<usize>
pub fn write(&mut self, data: &[u8], engine: EngineId) -> Result<usize>
Write data to the overflow region and return the slot index.
First attempts to reuse a freed slot from the free-list (best-fit). Falls back to bump allocation if no suitable free slot exists.
Sourcepub fn read(&self, slot_index: usize) -> Result<&[u8]>
pub fn read(&self, slot_index: usize) -> Result<&[u8]>
Read data from a slot (returns a slice into the mmap).
Sourcepub fn free(&mut self, slot_index: usize) -> Result<()>
pub fn free(&mut self, slot_index: usize) -> Result<()>
Mark a slot as freed and add it to the free-list for reuse.
Sourcepub fn used_bytes(&self) -> usize
pub fn used_bytes(&self) -> usize
Current utilization of the mmap region in bytes.
Sourcepub fn slot_count(&self) -> usize
pub fn slot_count(&self) -> usize
Number of slots (occupied or freed).