Skip to content

Commit 59872ab

Browse files
test: add new logs
1 parent 2b894c7 commit 59872ab

2 files changed

Lines changed: 28 additions & 16 deletions

File tree

crates/trie/parallel/src/parallel_root.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,16 @@ where
132132
let mut hash_builder = HashBuilder::default().with_updates(retain_updates);
133133
let mut account_rlp = Vec::with_capacity(128);
134134
let start = std::time::Instant::now();
135-
let mut hash_elapsed = 0;
135+
let mut hash_elapsed_branch = 0;
136+
let mut hash_elapsed_leaf = 0;
137+
let mut hash_elapsed_miss = 0;
136138
while let Some(node) = account_node_iter.try_next().map_err(ProviderError::Database)? {
137-
let start = std::time::Instant::now();
138139
match node {
139140
TrieElement::Branch(node) => {
141+
let start = std::time::Instant::now();
140142
tracker.inc_branch();
141143
hash_builder.add_branch(node.key, node.value, node.children_are_in_trie);
144+
hash_elapsed_branch += start.elapsed().as_micros();
142145
}
143146
TrieElement::Leaf(hashed_address, account) => {
144147
let (storage_root, _, updates) = match storage_roots.remove(&hashed_address) {
@@ -149,34 +152,43 @@ where
149152
// Since we do not store all intermediate nodes in the database, there might
150153
// be a possibility of re-adding a non-modified leaf to the hash builder.
151154
None => {
155+
let start = std::time::Instant::now();
152156
tracker.inc_missed_leaves();
153-
StorageRoot::new_hashed(
157+
let result = StorageRoot::new_hashed(
154158
trie_cursor_factory.clone(),
155159
hashed_cursor_factory.clone(),
156160
hashed_address,
157161
#[cfg(feature = "metrics")]
158162
self.metrics.storage_trie.clone(),
159163
)
160-
.calculate(retain_updates)?
164+
.calculate(retain_updates)?;
165+
hash_elapsed_miss += start.elapsed().as_micros();
166+
167+
result
161168
}
162169
};
163170

164171
if retain_updates {
165172
trie_updates.insert_storage_updates(hashed_address, updates);
166173
}
167174

175+
let start = std::time::Instant::now();
168176
account_rlp.clear();
169177
let account = TrieAccount::from((account, storage_root));
170178
account.encode(&mut account_rlp as &mut dyn BufMut);
171179
hash_builder.add_leaf(Nibbles::unpack(hashed_address), &account_rlp);
180+
hash_elapsed_leaf += start.elapsed().as_micros();
172181
}
173182
}
174-
hash_elapsed += start.elapsed().as_micros();
175183
}
176184
debug!(target: "trie::parallel_state_root", "test info: total elapsed in account node {:?}", start.elapsed());
177-
debug!(target: "trie::parallel_state_root", "test info: hash elapsed in account node {:?}us", hash_elapsed);
185+
debug!(target: "trie::parallel_state_root", "test info: hash elapsed in account node {:?}us", hash_elapsed_branch);
186+
debug!(target: "trie::parallel_state_root", "test info: hash elapsed in account node {:?}us", hash_elapsed_leaf);
187+
debug!(target: "trie::parallel_state_root", "test info: hash elapsed in account node {:?}us", hash_elapsed_miss);
178188

189+
let start = std::time::Instant::now();
179190
let root = hash_builder.root();
191+
debug!(target: "trie::parallel_state_root", "test info: elapsed in hash builder root {:?}", start.elapsed());
180192

181193
trie_updates.finalize(
182194
account_node_iter.walker,

crates/trie/prefetch/src/prefetch.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ impl TriePrefetch {
7979
let hashed_state = self.deduplicate_and_update_cached(state);
8080

8181
let self_clone = Arc::new(self.clone());
82-
let global_stats = Arc::clone(&self.global_stats);
82+
// let global_stats = Arc::clone(&self.global_stats);
8383
join_set.spawn(async move {
84-
if let Err(e) = self_clone.prefetch_once::<DB>(consistent_view, hashed_state, global_stats).await {
84+
if let Err(e) = self_clone.prefetch_once::<DB>(consistent_view, hashed_state).await {
8585
debug!(target: "trie::trie_prefetch", ?e, "Error while prefetching trie storage");
8686
};
8787
});
@@ -90,7 +90,7 @@ impl TriePrefetch {
9090
_ = &mut interrupt_rx => {
9191
debug!(target: "trie::trie_prefetch", "Interrupted trie prefetch task. Unprocessed tx {:?}", prefetch_rx.len());
9292
join_set.abort_all();
93-
debug!(target: "trie::trie_prefetch", "test info: prefetch trie node count: {:?}", self.global_stats.lock().await);
93+
// debug!(target: "trie::trie_prefetch", "test info: prefetch trie node count: {:?}", self.global_stats.lock().await);
9494
return
9595
}
9696
}
@@ -152,7 +152,7 @@ impl TriePrefetch {
152152
self: Arc<Self>,
153153
consistent_view: Arc<ConsistentDbView<DB, ProviderFactory<DB>>>,
154154
hashed_state: HashedPostState,
155-
global_stats: Arc<Mutex<GlobalStats>>,
155+
// global_stats: Arc<Mutex<GlobalStats>>,
156156
) -> Result<(), TriePrefetchError>
157157
where
158158
DB: Database,
@@ -213,21 +213,21 @@ impl TriePrefetch {
213213
match node {
214214
TrieElement::Branch(_) => {
215215
tracker.inc_branch();
216-
let mut stats = global_stats.lock().await;
217-
stats.branch_count += 1;
216+
// let mut stats = global_stats.lock().await;
217+
// stats.branch_count += 1;
218218
}
219219
TrieElement::Leaf(hashed_address, _) => {
220220
match storage_roots.remove(&hashed_address) {
221221
Some(result) => {
222-
let mut stats = global_stats.lock().await;
223-
stats.leaf_count += 1;
222+
// let mut stats = global_stats.lock().await;
223+
// stats.leaf_count += 1;
224224
result
225225
}
226226
// Since we do not store all intermediate nodes in the database, there might
227227
// be a possibility of re-adding a non-modified leaf to the hash builder.
228228
None => {
229-
let mut stats = global_stats.lock().await;
230-
stats.missing_count += 1;
229+
// let mut stats = global_stats.lock().await;
230+
// stats.missing_count += 1;
231231

232232
StorageRoot::new_hashed(
233233
trie_cursor_factory.clone(),

0 commit comments

Comments
 (0)