Skip to main content

weir/ifds_resident_cache/
stats.rs

1/// Runtime counters for [`super::ResidentIfdsCsrCache`].
2#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
3pub struct ResidentIfdsCsrCacheStats {
4    /// Successful resident CSR lookups that avoided a graph upload.
5    pub hits: u64,
6    /// Lookups that had to upload invariant CSR buffers.
7    pub misses: u64,
8    /// Resident CSR graph uploads performed by this cache.
9    pub resident_uploads: u64,
10    /// Cumulative resident CSR graph bytes uploaded by this cache.
11    pub resident_upload_bytes: u64,
12    /// Cumulative resident CSR graph upload bytes avoided by cache hits.
13    pub resident_avoided_upload_bytes: u64,
14    /// Resident CSR entries evicted to stay within the retained-byte limit.
15    pub evictions: u64,
16    /// Current resident graph bytes retained by the cache.
17    pub retained_bytes: usize,
18    /// Current resident CSR entry count.
19    pub entries: usize,
20}
21
22impl ResidentIfdsCsrCacheStats {
23    /// Backend-neutral resident graph reuse telemetry for this cache snapshot.
24    #[must_use]
25    pub const fn resident_graph_reuse_telemetry(self) -> vyre::ResidentGraphReuseTelemetry {
26        vyre::ResidentGraphReuseTelemetry::from_counters(
27            self.misses,
28            self.hits,
29            self.resident_upload_bytes,
30            self.resident_avoided_upload_bytes,
31        )
32    }
33}