Skip to main content

PrefixCache

Struct PrefixCache 

Source
pub struct PrefixCache {
    pub entries: Vec<CacheEntry>,
    pub changed: bool,
}

Fields§

§entries: Vec<CacheEntry>§changed: bool

An entry came in or was used since the cache last settled, so an export may have come to be covered.

Implementations§

Source§

impl PrefixCache

Source

pub fn insert( &mut self, seq: Seq, tokens: Vec<u32>, prompt: u64, bytes: u64, now: u64, )

Source

pub fn get(&self, seq: Seq) -> Option<&CacheEntry>

Source

pub fn remove(&mut self, seq: Seq) -> Option<CacheEntry>

Take the entry out of the cache.

Source

pub fn resident(&self) -> Vec<Seq> ⓘ

The sequences of the entries in the pool.

Source

pub fn exported_tokens(&self) -> u64

Tokens of state held out of the pool.

Source

pub fn exported_bytes(&self) -> u64

Host bytes the exports hold.

Source

pub fn best_prefix( &self, span: &[u32], page: u64, exact_only: bool, ) -> Option<(usize, u64)>

Source

pub fn candidates( &self, span: &[u32], page: u64, exact_only: bool, ) -> Vec<(u64, Seq)>

Source

pub fn unpinned_bytes(&self) -> u64

Pool bytes an eviction could free: the entries in the pool no lease pins.

Source

pub fn resident_bytes(&self) -> u64

Pool bytes the cache accounts for.

Source

pub fn plan_evict( &self, target: u64, cap: u64, shared_too: bool, ) -> (u64, Vec<usize>)

Source

pub fn plan_evict_until( &self, cap: u64, enough: impl FnMut(&[usize]) -> bool, ) -> (Vec<usize>, bool)

Source

pub fn bytes_of(&self, indices: &[usize]) -> u64

Source

pub fn evict_digests(&mut self, digests: &[[u8; 32]]) -> Vec<(Seq, bool)>

Takes the unpinned entries whose tokens carry one of digests out of the cache, and names them with whether each was in the pool.

Source

pub fn evict_exact(&mut self, tokens: &[u32]) -> Vec<(Seq, bool)>

Removes the entries keyed by exactly tokens that no seed holds.

Trait Implementations§

Source§

impl Default for PrefixCache

Source§

fn default() -> Self

Returns the “default value” for a 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.