Skip to main content

ResidencyPlan

Struct ResidencyPlan 

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

The residency labels a bank load asked for, and the ones it got.

The loader walks layers, calls settle_action for each, does the syscall itself, and reports back with record / record_lock. Nothing here touches memory: this side owns the bookkeeping, the caller owns the syscall. achieved_labels is what then feeds BankResidency::new – the achieved labels, never the requested ones.

Implementations§

Source§

impl ResidencyPlan

Source

pub fn new(requested: Vec<HostResidency>) -> Self

Source

pub fn all_pinned(num_layers: usize) -> Self

The no-split plan: every layer pinned, which is what a host with no pin cap always does.

Source

pub fn num_layers(&self) -> usize

Source

pub fn has_unpinned(&self) -> bool

Whether any layer was asked to be something other than pinned. A plan with none of them is indistinguishable from no plan.

Source

pub fn applied(&self) -> bool

Whether any settle point consulted this plan.

A loader that pins everything by construction never asks, and its banks are all pinned no matter what was requested. That is still a working load – CPU-layer decode reads a pinned bank perfectly well – it just saved no pin quota, so the honest report is “not applied”, not the labels that were wished for.

Source

pub fn lock_quota_exhausted(&self) -> bool

Whether a lock has already failed.

The OS lock ceiling is a per-process quota, so once one request is over it every later (larger cumulative) request is too. Sticky, therefore, rather than retried per bank: retrying buys nothing and turns one failure into one failed syscall per bank for the rest of the load.

Source

pub fn requested(&self, layer_id: usize) -> HostResidency

The class layer layer_id was asked for.

§Panics

If layer_id is not a layer of this plan.

Source

pub fn settle_action(&mut self, layer_id: usize) -> SettleAction

What to do with layer layer_id’s freshly filled bank, marking the plan applied.

Returns SettleAction::LeavePageable for a Locked layer once the lock quota is known to be exhausted – the syscall would fail anyway, and the bank ends up pageable either way.

§Panics

If layer_id is not a layer of this plan.

Source

pub fn record(&mut self, layer_id: usize, achieved: HostResidency)

Record what one of layer layer_id’s banks actually settled at.

A layer is several banks and is only as resident as its worst one, so once a layer has recorded HostResidency::Pageable no later, better, report can raise it again.

§Panics

If layer_id is not a layer of this plan.

Source

pub fn record_lock(&mut self, layer_id: usize, locked: bool)

Record the outcome of one lock attempt: locked false means the bank is pageable and the quota is spent for the rest of the load.

§Panics

If layer_id is not a layer of this plan.

Source

pub fn achieved(&self, layer_id: usize) -> Option<HostResidency>

What layer layer_id settled at, or None if no bank of it reported.

§Panics

If layer_id is not a layer of this plan.

Source

pub fn achieved_labels(&self) -> Vec<HostResidency>

The labels to hand BankResidency::new: what was achieved where anything reported, what was requested elsewhere.

A pinned layer never reports, because a failed pin is a hard error the loader raises rather than a downgrade – there is no second way to serve a GPU layer.

Source

pub fn downgraded(&self) -> Vec<u32>

The layers that did not get what they asked for, for the one warning a human needs to see: they still decode on the CPU executor, but they may now swap under memory pressure.

Trait Implementations§

Source§

impl Clone for ResidencyPlan

Source§

fn clone(&self) -> ResidencyPlan

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ResidencyPlan

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for ResidencyPlan

Source§

impl PartialEq for ResidencyPlan

Source§

fn eq(&self, other: &ResidencyPlan) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ResidencyPlan

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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, !>

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.