@@ -1238,43 +1238,50 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, []
12381238 return it .index , events , coalescedLogs , err
12391239 }
12401240 // Process block using the parent state as reference point.
1241- t0 := time .Now ()
1241+ substart := time .Now ()
12421242 receipts , logs , usedGas , err := bc .processor .Process (block , state , bc .vmConfig )
1243- t1 := time .Now ()
12441243 if err != nil {
12451244 bc .reportBlock (block , receipts , err )
12461245 return it .index , events , coalescedLogs , err
12471246 }
1247+ // Update the metrics touched during block processing
1248+ accountReadTimer .Update (state .AccountReads ) // Account reads are complete, we can mark them
1249+ storageReadTimer .Update (state .StorageReads ) // Storage reads are complete, we can mark them
1250+ accountUpdateTimer .Update (state .AccountUpdates ) // Account updates are complete, we can mark them
1251+ storageUpdateTimer .Update (state .StorageUpdates ) // Storage updates are complete, we can mark them
1252+
1253+ triehash := state .AccountHashes + state .StorageHashes // Save to not double count in validation
1254+ trieproc := state .AccountReads + state .AccountUpdates
1255+ trieproc += state .StorageReads + state .StorageUpdates
1256+
1257+ blockExecutionTimer .Update (time .Since (substart ) - trieproc - triehash )
1258+
12481259 // Validate the state using the default validator
1260+ substart = time .Now ()
12491261 if err := bc .Validator ().ValidateState (block , state , receipts , usedGas ); err != nil {
12501262 bc .reportBlock (block , receipts , err )
12511263 return it .index , events , coalescedLogs , err
12521264 }
1253- t2 := time .Now ()
12541265 proctime := time .Since (start )
12551266
1267+ // Update the metrics touched during block validation
1268+ accountHashTimer .Update (state .AccountHashes ) // Account hashes are complete, we can mark them
1269+ storageHashTimer .Update (state .StorageHashes ) // Storage hashes are complete, we can mark them
1270+
1271+ blockValidationTimer .Update (time .Since (substart ) - (state .AccountHashes + state .StorageHashes - triehash ))
1272+
12561273 // Write the block to the chain and get the status.
1274+ substart = time .Now ()
12571275 status , err := bc .writeBlockWithState (block , receipts , state )
1258- t3 := time .Now ()
12591276 if err != nil {
12601277 return it .index , events , coalescedLogs , err
12611278 }
1279+ // Update the metrics touched during block commit
1280+ accountCommitTimer .Update (state .AccountCommits ) // Account commits are complete, we can mark them
1281+ storageCommitTimer .Update (state .StorageCommits ) // Storage commits are complete, we can mark them
12621282
1263- // Update the metrics subsystem with all the measurements
1264- accountReadTimer .Update (state .AccountReads )
1265- accountHashTimer .Update (state .AccountHashes )
1266- accountUpdateTimer .Update (state .AccountUpdates )
1267- accountCommitTimer .Update (state .AccountCommits )
1268-
1269- storageReadTimer .Update (state .StorageReads )
1270- storageHashTimer .Update (state .StorageHashes )
1271- storageUpdateTimer .Update (state .StorageUpdates )
1272- storageCommitTimer .Update (state .StorageCommits )
1273-
1283+ blockWriteTimer .Update (time .Since (substart ) - state .AccountCommits - state .StorageCommits )
12741284 blockInsertTimer .UpdateSince (start )
1275- blockExecutionTimer .Update (t1 .Sub (t0 ) - state .AccountReads - state .AccountUpdates - state .StorageReads - state .StorageUpdates )
1276- blockValidationTimer .Update (t2 .Sub (t1 ) - state .AccountHashes - state .StorageHashes )
1277- blockWriteTimer .Update (t3 .Sub (t2 ) - state .AccountCommits - state .StorageCommits )
12781285
12791286 switch status {
12801287 case CanonStatTy :
0 commit comments