@@ -1752,44 +1752,45 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals, setHead bool)
17521752 }
17531753
17541754 // Process block using the parent state as reference point
1755- substart := time .Now ()
1755+ pstart := time .Now ()
17561756 receipts , logs , usedGas , err := bc .processor .Process (block , statedb , bc .vmConfig )
17571757 if err != nil {
17581758 bc .reportBlock (block , receipts , err )
17591759 atomic .StoreUint32 (& followupInterrupt , 1 )
17601760 return it .index , err
17611761 }
1762+ ptime := time .Since (pstart )
17621763
1763- // Update the metrics touched during block processing
1764- accountReadTimer .Update (statedb .AccountReads ) // Account reads are complete, we can mark them
1765- storageReadTimer .Update (statedb .StorageReads ) // Storage reads are complete, we can mark them
1766- accountUpdateTimer .Update (statedb .AccountUpdates ) // Account updates are complete, we can mark them
1767- storageUpdateTimer .Update (statedb .StorageUpdates ) // Storage updates are complete, we can mark them
1768- snapshotAccountReadTimer .Update (statedb .SnapshotAccountReads ) // Account reads are complete, we can mark them
1769- snapshotStorageReadTimer .Update (statedb .SnapshotStorageReads ) // Storage reads are complete, we can mark them
1770- triehash := statedb .AccountHashes + statedb .StorageHashes // Save to not double count in validation
1771- trieproc := statedb .SnapshotAccountReads + statedb .AccountReads + statedb .AccountUpdates
1772- trieproc += statedb .SnapshotStorageReads + statedb .StorageReads + statedb .StorageUpdates
1773-
1774- blockExecutionTimer .Update (time .Since (substart ) - trieproc - triehash )
1775-
1776- // Validate the state using the default validator
1777- substart = time .Now ()
1764+ vstart := time .Now ()
17781765 if err := bc .validator .ValidateState (block , statedb , receipts , usedGas ); err != nil {
17791766 bc .reportBlock (block , receipts , err )
17801767 atomic .StoreUint32 (& followupInterrupt , 1 )
17811768 return it .index , err
17821769 }
1783- proctime := time .Since (start )
1784-
1785- // Update the metrics touched during block validation
1786- accountHashTimer .Update (statedb .AccountHashes ) // Account hashes are complete, we can mark them
1787- storageHashTimer .Update (statedb .StorageHashes ) // Storage hashes are complete, we can mark them
1788- blockValidationTimer .Update (time .Since (substart ) - (statedb .AccountHashes + statedb .StorageHashes - triehash ))
1770+ vtime := time .Since (vstart )
1771+ proctime := time .Since (start ) // processing + validation
1772+
1773+ // Update the metrics touched during block processing and validation
1774+ accountReadTimer .Update (statedb .AccountReads ) // Account reads are complete(in processing)
1775+ storageReadTimer .Update (statedb .StorageReads ) // Storage reads are complete(in processing)
1776+ snapshotAccountReadTimer .Update (statedb .SnapshotAccountReads ) // Account reads are complete(in processing)
1777+ snapshotStorageReadTimer .Update (statedb .SnapshotStorageReads ) // Storage reads are complete(in processing)
1778+ accountUpdateTimer .Update (statedb .AccountUpdates ) // Account updates are complete(in validation)
1779+ storageUpdateTimer .Update (statedb .StorageUpdates ) // Storage updates are complete(in validation)
1780+ accountHashTimer .Update (statedb .AccountHashes ) // Account hashes are complete(in validation)
1781+ storageHashTimer .Update (statedb .StorageHashes ) // Storage hashes are complete(in validation)
1782+ triehash := statedb .AccountHashes + statedb .StorageHashes // The time spent on tries hashing
1783+ trieUpdate := statedb .AccountUpdates + statedb .StorageUpdates // The time spent on tries update
1784+ trieRead := statedb .SnapshotAccountReads + statedb .AccountReads // The time spent on account read
1785+ trieRead += statedb .SnapshotStorageReads + statedb .StorageReads // The time spent on storage read
1786+ blockExecutionTimer .Update (ptime - trieRead ) // The time spent on EVM processing
1787+ blockValidationTimer .Update (vtime - (triehash + trieUpdate )) // The time spent on block validation
17891788
17901789 // Write the block to the chain and get the status.
1791- substart = time .Now ()
1792- var status WriteStatus
1790+ var (
1791+ wstart = time .Now ()
1792+ status WriteStatus
1793+ )
17931794 if ! setHead {
17941795 // Don't set the head, only insert the block
17951796 err = bc .writeBlockWithState (block , receipts , statedb )
@@ -1804,9 +1805,9 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals, setHead bool)
18041805 accountCommitTimer .Update (statedb .AccountCommits ) // Account commits are complete, we can mark them
18051806 storageCommitTimer .Update (statedb .StorageCommits ) // Storage commits are complete, we can mark them
18061807 snapshotCommitTimer .Update (statedb .SnapshotCommits ) // Snapshot commits are complete, we can mark them
1807- triedbCommitTimer .Update (statedb .TrieDBCommits ) // Triedb commits are complete, we can mark them
1808+ triedbCommitTimer .Update (statedb .TrieDBCommits ) // Trie database commits are complete, we can mark them
18081809
1809- blockWriteTimer .Update (time .Since (substart ) - statedb .AccountCommits - statedb .StorageCommits - statedb .SnapshotCommits - statedb .TrieDBCommits )
1810+ blockWriteTimer .Update (time .Since (wstart ) - statedb .AccountCommits - statedb .StorageCommits - statedb .SnapshotCommits - statedb .TrieDBCommits )
18101811 blockInsertTimer .UpdateSince (start )
18111812
18121813 // Report the import stats before returning the various results
0 commit comments