Skip to main content

SpillCtx

Struct SpillCtx 

Source
pub struct SpillCtx {
    pub file_maps: Vec<Arc<Mmap>>,
    pub files: Vec<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 PER SHARD 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_maps: Vec<Arc<Mmap>>

One MAP_SHARED mmap per physical GGUF shard, shared (Arc) across every spilled expert block that lives in that shard. Index = TensorInfo::shard. Single-file models have len 1. PER-SHARD, not one map: a split model’s tensor_file_range offsets are relative to the OWNING shard’s file, so pairing them with shard 0’s mmap would read the wrong bytes (and would index out of bounds for any shard larger than shard 0).

§files: Vec<Arc<File>>

The opened inodes backing file_maps, same indexing, retained for 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 each parsed shard’s opened inode, create a MAP_SHARED mmap per shard, 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.