Skip to main content

MetadataCachePolicy

Struct MetadataCachePolicy 

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

Every caching decision, in one place. Given an info’s size and the current CacheMode, the policy decides whether that info is cached at all (should_cache) and, through its capacity, when the cache must evict to stay bounded. How those decisions are carried out (lookups, eviction) is the cache’s job and differs per runtime; what to do lives here.

max_entries and max_cached_size are the backend-tunable knobs.

Implementations§

Source§

impl MetadataCachePolicy

Source

pub fn new(max_entries: usize, max_cached_size: usize) -> Self

Build a policy in CacheMode::Normal. max_entries caps the number of cached entries; max_cached_size (bytes) is the largest info still worth caching in normal operation.

Source

pub fn mode(&mut self, mode: CacheMode)

Switch the mode driving the policy’s decisions (see CacheMode).

Source

pub fn should_cache(&self, size: usize) -> bool

Whether an info of size bytes should go through the cache at all. In CacheMode::Normal a too-large info (or a disabled cache) is skipped: the runtime should create it directly, without a lookup or a store. In CacheMode::Capture everything is cached so the capture window stays warm.

Source

pub fn capacity(&self) -> Option<usize>

The entry bound the cache must hold to, or None when unbounded. In CacheMode::Capture the cache is unbounded and never evicts (dropping an entry could free a buffer a recorded launch still needs); in CacheMode::Normal it is capped at max_entries.

Source

pub fn pins_entries(&self) -> bool

Whether entries touched right now must be pinned to the graph being captured. True in CacheMode::Capture: a graph records the device pointer of every info buffer its launches touch, so those entries must not be evicted for the graph’s lifetime — even after the cache returns to CacheMode::Normal, and even if the buffer lives in the regular (non-persistent) pool and so is not otherwise retained by the graph.

Trait Implementations§

Source§

impl Clone for MetadataCachePolicy

Source§

fn clone(&self) -> MetadataCachePolicy

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 Copy for MetadataCachePolicy

Source§

impl Debug for MetadataCachePolicy

Source§

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

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

impl Default for MetadataCachePolicy

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

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 = 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.
Source§

impl<T> TuneInputs for T
where T: Clone + Send + Sync + 'static,

Source§

type At<'a> = T

The concrete input type at lifetime 'a.