@@ -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 ,
0 commit comments