pub struct PrefetchScheduler { /* private fields */ }Expand description
Tracks CID access patterns and suggests prefetch candidates.
A sliding window of the last 256 accesses is maintained. Within each access event the scheduler updates co-access counts for up to the 4 most-recent other CIDs (i.e., pairs within the last 5 accesses).
Implementations§
Source§impl PrefetchScheduler
impl PrefetchScheduler
Sourcepub fn record_access(&self, cid: &str)
pub fn record_access(&self, cid: &str)
Record that cid was accessed.
Appends to the rolling log (trimmed to 256 entries) and updates co-access counts for all pairs formed by the current access and the preceding 4 entries (window of 5).
Sourcepub fn prefetch_candidates(&self, cid: &str, top_n: usize) -> Vec<String>
pub fn prefetch_candidates(&self, cid: &str, top_n: usize) -> Vec<String>
Return the top top_n CIDs most frequently co-accessed with cid,
sorted by co-access count descending.
Sourcepub fn access_count(&self) -> usize
pub fn access_count(&self) -> usize
Return the total number of entries in the access log.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for PrefetchScheduler
impl RefUnwindSafe for PrefetchScheduler
impl Send for PrefetchScheduler
impl Sync for PrefetchScheduler
impl Unpin for PrefetchScheduler
impl UnsafeUnpin for PrefetchScheduler
impl UnwindSafe for PrefetchScheduler
Blanket Implementations§
impl<T> Allocation for T
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>
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 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>
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