Skip to main content

SpillCtx

Struct SpillCtx 

Source
pub struct SpillCtx {
    pub file_map: Arc<Mmap>,
    pub file: Arc<File>,
    pub pinned_remaining: usize,
    pub n_pinned: usize,
    pub n_mmap: usize,
    pub mmap_bytes: usize,
}
Expand description

Shared load-time spill context (SPILLING-PLAN §2 step 4). Built ONCE per model load when the disk tier is on, then handed by &mut to each HostExps::load so all layers/projections share ONE file mmap and draw down a single running pinned-RAM budget. Greedy in load order: pin until pinned_remaining is exhausted, then spill every later expert to Mmap.

Fields§

§file_map: Arc<Mmap>

One MAP_SHARED mmap of the whole GGUF, shared (Arc) across every spilled expert block.

§file: Arc<File>

The same opened inode backing file_map, retained for future positioned expert reads.

§pinned_remaining: usize

Pinned-RAM budget still available (bytes); decremented as experts are pinned.

§n_pinned: usize

Diagnostics: how many experts landed pinned vs. mmap’d, and total disk-tier bytes.

§n_mmap: usize§mmap_bytes: usize

Implementations§

Source§

impl SpillCtx

Source

pub fn open(g: &GgufFile, budget: &MemBudget) -> Result<Self, Box<dyn Error>>

Clone the parsed GGUF’s opened inode, create a MAP_SHARED mmap from it, and seed the pinned budget from a live MemBudget probe. The whole-map expert advice defaults to random (the historical behavior); setting MEMRA_MOE_MMAP_ADVICE=normal restores ordinary Linux readahead. SPILLING-PLAN §1.

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, 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.