pub struct StatCache<T> { /* private fields */ }Expand description
A parse cache keyed by a file’s (mtime, len): the file is re-read and
re-parsed only when its stat changes.
For pollers reading run state on a tick. The dashboard synced at 10Hz by
re-parsing every run’s meta.json, stages.json, and whole
context.json; with 50 runs on disk that was on the order of 100 MB/s of
allocate-and-parse-and-free for files that change at most once per persist
tick. A stat costs microseconds; this turns the steady-state tick into
stats plus clones of shared Arcs.
(mtime, len) rather than mtime alone: the persistence lane’s atomic
rename gives every update a fresh temp inode and mtime, but coarse mtime
granularity on some filesystems can miss two updates in the same instant -
the length check catches most of those, and a same-length same-instant
rewrite is indistinguishable anyway one tick later.
Implementations§
Source§impl<T> StatCache<T>
impl<T> StatCache<T>
Sourcepub fn get_with(
&mut self,
path: &Path,
parse: impl FnOnce(&str) -> Option<T>,
) -> Option<Arc<T>>
pub fn get_with( &mut self, path: &Path, parse: impl FnOnce(&str) -> Option<T>, ) -> Option<Arc<T>>
The value parsed from path, re-reading only when the file’s stat
changed since the last call. None when the file is missing,
unreadable, or parse rejects it - negative results are cached too, so
a persistently-bad file costs one stat per tick, not one parse.
Sourcepub fn retain_under(&mut self, keep: &HashSet<PathBuf>)
pub fn retain_under(&mut self, keep: &HashSet<PathBuf>)
Drop entries for files under runs that no longer exist, so a long-lived poller’s cache stays bounded by the live run set.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for StatCache<T>
impl<T> RefUnwindSafe for StatCache<T>where
T: RefUnwindSafe,
impl<T> Send for StatCache<T>
impl<T> Sync for StatCache<T>
impl<T> Unpin for StatCache<T>
impl<T> UnsafeUnpin for StatCache<T>
impl<T> UnwindSafe for StatCache<T>where
T: RefUnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ConditionalSend for Twhere
T: Send,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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