Skip to main content

OverflowRegion

Struct OverflowRegion 

Source
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

Source

pub const DEFAULT_INITIAL_CAPACITY: usize

Default initial mmap size.

Corresponds to MemoryTuning::overflow_initial_bytes.

Source

pub const DEFAULT_MAX_CAPACITY: usize

Default maximum capacity (prevents unbounded growth).

Corresponds to MemoryTuning::overflow_max_bytes.

Source

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.

Source

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.

Source

pub fn open_with_capacity(path: &Path, initial_capacity: usize) -> Result<Self>

Open or create an overflow region with a specific initial capacity.

Source

pub fn madvise_state(&self) -> Option<c_int>

The madvise hint currently in effect on the mapped region.

Source

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.

Source

pub fn read(&self, slot_index: usize) -> Result<&[u8]>

Read data from a slot (returns a slice into the mmap).

Source

pub fn free(&mut self, slot_index: usize) -> Result<()>

Mark a slot as freed and add it to the free-list for reuse.

Source

pub fn used_bytes(&self) -> usize

Current utilization of the mmap region in bytes.

Source

pub fn capacity(&self) -> usize

Total capacity of the mmap region in bytes.

Source

pub fn path(&self) -> &Path

Path to the backing overflow file.

Source

pub fn slot_count(&self) -> usize

Number of slots (occupied or freed).

Trait Implementations§

Source§

impl Drop for OverflowRegion

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more