Skip to main content

reth_storage_overlay/
manager_metrics.rs

1use reth_metrics::{
2    metrics::{Counter, Histogram},
3    Metrics,
4};
5
6/// Metrics for state trie overlay management.
7#[derive(Clone, Metrics)]
8#[metrics(scope = "sync.block_validation.state_trie_overlay")]
9pub(crate) struct StateTrieOverlayMetrics {
10    /// Duration of overlay computation in seconds.
11    pub(crate) overlay_computation_duration_seconds: Histogram,
12    /// Number of requests satisfied by an existing overlay cache entry.
13    pub(crate) overlay_cache_reuses: Counter,
14    /// Number of overlay cache entries populated by computing an overlay.
15    pub(crate) overlay_cache_fills: Counter,
16}
17
18/// Metrics for execution overlay management.
19#[derive(Clone, Metrics)]
20#[metrics(scope = "sync.block_validation.execution_overlay")]
21pub(crate) struct ExecutionOverlayMetrics {
22    /// Duration of overlay computation in seconds.
23    pub(crate) overlay_computation_duration_seconds: Histogram,
24    /// Number of requests satisfied by an existing overlay cache entry.
25    pub(crate) overlay_cache_reuses: Counter,
26    /// Number of overlay cache entries populated by computing an overlay.
27    pub(crate) overlay_cache_fills: Counter,
28}
29
30pub(crate) trait OverlayCacheMetrics {
31    fn record_cache_reuse(&self);
32
33    fn record_cache_fill(&self);
34}
35
36impl OverlayCacheMetrics for StateTrieOverlayMetrics {
37    fn record_cache_reuse(&self) {
38        self.overlay_cache_reuses.increment(1);
39    }
40
41    fn record_cache_fill(&self) {
42        self.overlay_cache_fills.increment(1);
43    }
44}
45
46impl OverlayCacheMetrics for ExecutionOverlayMetrics {
47    fn record_cache_reuse(&self) {
48        self.overlay_cache_reuses.increment(1);
49    }
50
51    fn record_cache_fill(&self) {
52        self.overlay_cache_fills.increment(1);
53    }
54}