1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//! Cache accounting primitives shared by tensor backends and facade runtimes.
/// Entry, retained-byte, and event accounting for one cache.
///
/// `retained_bytes` reports the cache-owned logical payload estimate. It does
/// not include allocator arena slack, operating-system RSS, or memory retained
/// by unrelated process allocators.
///
/// # Examples
///
/// ```
/// use tenferro_tensor::CacheStats;
///
/// let stats = CacheStats {
/// entries: 2,
/// retained_bytes: 128,
/// hits: 3,
/// misses: 4,
/// evictions: 0,
/// clears: 0,
/// };
/// assert_eq!(stats.entries, 2);
/// assert_eq!(stats.retained_bytes, 128);
/// assert_eq!(stats.hits, 3);
/// ```
/// Control surface required for backend runtime caches owned by higher-level runtimes.
///
/// Backend caches use this trait so higher-level runtimes and executors can
/// clear and inspect the cache without knowing backend-specific entry types.
///
/// # Examples
///
/// ```
/// use tenferro_tensor::{CacheStats, RuntimeCacheControl};
///
/// let mut cache = ();
/// assert_eq!(cache.stats(), CacheStats::empty());
/// cache.clear();
/// assert_eq!(cache.stats().entries, 0);
/// ```