Mountain/Cache/PathCanon/SpawnDiagnosticLogger.rs
1
2//! Spawn a tokio task that logs cache stats every 30 s under the `path-canon`
3//! trace tag. Optional; call from `RunTime::Setup` when the user has
4//! `Trace=path-canon` enabled.
5
6use std::time::Duration;
7
8use crate::{Cache::PathCanon::Stats, dev_log};
9
10pub fn Fn() {
11 tokio::spawn(async {
12 let mut Interval = tokio::time::interval(Duration::from_secs(30));
13
14 // skip the immediate first tick
15 Interval.tick().await;
16
17 loop {
18 Interval.tick().await;
19
20 let Snapshot = Stats::Fn();
21
22 dev_log!("path-canon", "entries={} weighted={}", Snapshot.Entries, Snapshot.WeightedSize);
23 }
24 });
25}