reth_trie_parallel/
stats.rs1#[cfg(feature = "metrics")]
2use crate::proof_task_metrics::ProofTaskCursorMetricsCache;
3use derive_more::Deref;
4use reth_trie::stats::{TrieStats, TrieTracker};
5
6#[derive(Deref, Clone, Copy, Debug)]
8pub struct ParallelTrieStats {
9 #[deref]
10 trie: TrieStats,
11 precomputed_storage_roots: u64,
12 missed_leaves: u64,
13}
14
15impl ParallelTrieStats {
16 pub const fn trie_stats(&self) -> TrieStats {
18 self.trie
19 }
20
21 pub const fn precomputed_storage_roots(&self) -> u64 {
23 self.precomputed_storage_roots
24 }
25
26 pub const fn missed_leaves(&self) -> u64 {
28 self.missed_leaves
29 }
30}
31
32#[derive(Deref, Default, Debug)]
34pub struct ParallelTrieTracker {
35 #[deref]
36 trie: TrieTracker,
37 precomputed_storage_roots: u64,
38 missed_leaves: u64,
39 #[cfg(feature = "metrics")]
40 pub cursor_metrics: ProofTaskCursorMetricsCache,
42}
43
44impl ParallelTrieTracker {
45 pub const fn set_precomputed_storage_roots(&mut self, count: u64) {
47 self.precomputed_storage_roots = count;
48 }
49
50 pub const fn inc_branch(&mut self) {
52 self.trie.inc_branch();
53 }
54
55 pub const fn inc_leaf(&mut self) {
57 self.trie.inc_leaf();
58 }
59
60 pub const fn inc_missed_leaves(&mut self) {
62 self.missed_leaves += 1;
63 }
64
65 pub fn finish(self) -> ParallelTrieStats {
67 ParallelTrieStats {
68 trie: self.trie.finish(),
69 precomputed_storage_roots: self.precomputed_storage_roots,
70 missed_leaves: self.missed_leaves,
71 }
72 }
73}