Skip to main content

ExpertSlots

Struct ExpertSlots 

Source
pub struct ExpertSlots { /* private fields */ }
Expand description

A bounded pool of expert slots, and the executor for the plans that fill it.

Holds no bytes: occupant is the pool’s own record of what the device contains, kept separately from the planner’s residency map on purpose. The two agreeing is the invariant; a single map could not disagree, and so could never reveal that a copy failed.

Implementations§

Source§

impl ExpertSlots

Source

pub fn new(geometry: SlotGeometry) -> Result<Self, SlotFault>

Builds a pool, refusing a geometry no plan could be valid against.

A zero-width bank is refused rather than tolerated: it would make every row size check pass trivially and every copy a no-op, so the pool would report warm plans forever while holding nothing.

Source

pub fn with_residency(self, residency: BankResidency) -> Self

Attaches the per-layer host residency this pool copies from.

Without it every layer is assumed device-addressable, which is what an all-pinned host actually is. With it, a plan for an unpinned layer is refused here rather than issued to a device that has no address for those host rows.

Source

pub fn geometry(&self) -> &SlotGeometry

Source

pub fn stats(&self) -> SlotStats

Source

pub fn reset_stats(&mut self)

Source

pub fn occupant(&self, slot: u32) -> Option<ExpertId>

Which expert the device holds in slot, as far as this pool knows. None for an empty slot and for one whose last copy failed.

Source

pub fn occupied(&self) -> usize

Slots currently holding a known expert.

Source

pub fn invalidate_slot(&mut self, slot: u32)

Marks a slot as holding nothing known. Idempotent.

Source

pub fn invalidate_all(&mut self)

Forgets the whole pool. The counters survive: they describe traffic that really happened, and a resize does not unmake it.

Source

pub fn resize(&mut self, slots: usize) -> Result<(), SlotFault>

Resizes the pool, dropping everything resident.

Slot ids are positions in an allocation that no longer exists, so keeping the occupancy map would point at other experts’ bytes – the same reasoning as ExpertCache::rebuild, and the two must be resized together or the planner will name slots this pool does not have.

Source

pub fn apply_copy_plan( &mut self, layer: u32, plan: &CopyPlan, rows: &dyn ExpertRows, device: &mut dyn SlotDevice, ) -> Result<Applied, SlotFault>

Applies an ensure plan: the LRU picked the slots, so this is the indexed device path and an unpinned layer cannot take it.

Source

pub fn apply_materialize( &mut self, layer: u32, plan: &CopyPlan, rows: &dyn ExpertRows, device: &mut dyn SlotDevice, ) -> Result<Applied, SlotFault>

Applies a materialize_layer plan: the whole layer, slot e for expert e. This is the one shape an unpinned layer accepts, because it needs no device alias for the host rows.

Source

pub fn apply_gather_plan( &mut self, plan: &GatherPlan, device: &mut dyn SlotDevice, ) -> Result<Applied, SlotFault>

Applies a GatherPlan: rows the prefill buffer can take from slots that already hold them, rather than from the host.

A source slot whose occupant is unknown is refused. The planner believes it is resident; this pool knows a copy into it failed, and gathering from it would propagate garbage into a second slot while both are recorded as valid.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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.