Skip to main content

Mountain/Cache/PathCanon/
SpawnDiagnosticLogger.rs

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