pub struct TinyLfuEstimator { /* private fields */ }Expand description
Shared W-TinyLFU frequency evidence: one sighting per served request from the serve path, one estimate read per fill-path admission decision and per probation candidate at sweep time.
The counters live in a ShardedCountMinSketch, so a sighting or an
estimate locks the one shard its hash routes to. Serve completions and
admission reads for different hashes therefore proceed in parallel, and the
periodic aging pass touches a single shard rather than the whole array.
Aging runs on one node-wide clock across all shards. Both readers below
compare estimates on a shared scale — ProbationAdmission against a
node-wide threshold, TinyLfuEviction by ranking candidates from
different shards against each other — so counters are only meaningful if
each is caught up to that one clock when it is read. A clock per shard would
age at a rate set by key skew and put the two readers on scales that cannot
be compared at all.
Implementations§
Source§impl TinyLfuEstimator
impl TinyLfuEstimator
Sourcepub fn new(sketch_bytes: usize) -> Self
pub fn new(sketch_bytes: usize) -> Self
Size the sketch to roughly sketch_bytes of counters: one u8 per
counter over ROWS rows, so cols = bytes / 4.
The floor of 64 columns is a backstop for callers outside config
resolution, which rejects a cache.tinylfu.sketch_bytes small enough to
reach it (decdn_common::config::MIN_TINYLFU_SKETCH_BYTES). It keeps the
width above super::sketch::SHARDS, below which a sharded sketch
degenerates to one column per shard (see ShardedCountMinSketch::new).
It is not a width the estimates read usefully at: 64 columns over
super::sketch::SHARDS shards is four columns per shard, and the
collision rate that matters is the per-shard one.
Trait Implementations§
Source§impl Debug for TinyLfuEstimator
impl Debug for TinyLfuEstimator
Auto Trait Implementations§
impl !Freeze for TinyLfuEstimator
impl RefUnwindSafe for TinyLfuEstimator
impl Send for TinyLfuEstimator
impl Sync for TinyLfuEstimator
impl Unpin for TinyLfuEstimator
impl UnsafeUnpin for TinyLfuEstimator
impl UnwindSafe for TinyLfuEstimator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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