Skip to main content

ResolveCache

Struct ResolveCache 

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

Process-lifetime LRU of StrHash → resolved string, shared by all queries on a compute node.

Uses StrHashIdentityBuildHasher — bucket selection is the hash’s upper 64 bits, no second SipHash — and enforces two budgets: Self::insert evicts least-recently-used entries until both the entry count (enforced by the LRU itself) and the byte budget hold. Cumulative hit/miss counters are reported in the phases: debug line.

Implementations§

Source§

impl ResolveCache

Source

pub fn from_env() -> Arc<Self>

Engine-wide cache with the env-tunable entry capacity (WARATAH_RESOLVE_CACHE_ENTRIES, KiB-style plain count; 0 disables) and the default byte budget.

Source

pub fn new(capacity_entries: usize, byte_budget: usize) -> Self

Cache holding at most capacity_entries strings and byte_budget summed string bytes. capacity_entries == 0 disables the cache: every lookup misses and inserts are dropped.

Source

pub fn probe(&self, hashes: &[StrHash]) -> (StrHashMap, Vec<StrHash>)

Probe hashes; returns cache hits as a map plus the ordered miss list (order-preserving, so registry-bound batches keep their sorted walk). Hits refresh their LRU recency; both counters accumulate.

Source

pub fn insert(&self, pairs: impl IntoIterator<Item = (StrHash, String)>)

Insert resolved strings, evicting least-recently-used entries until the byte budget holds. Unregistered hashes (None from the registry) are skipped by the caller.

Source

pub fn stats(&self) -> (u64, u64)

Cumulative (hits, misses) since process start.

Trait Implementations§

Source§

impl Debug for ResolveCache

Source§

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

Formats the value using the given formatter. 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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
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 = 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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

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

§

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

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,