Skip to content

Commit

Permalink
fix trie timing metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-ogrady committed Nov 2, 2022
1 parent 19716c0 commit 6bb9d01
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -1194,15 +1194,12 @@ func (bc *BlockChain) insertBlock(block *types.Block, writes bool) error {
// Update the metrics touched during block processing
accountReadTimer.Inc(statedb.AccountReads.Milliseconds()) // Account reads are complete, we can mark them
storageReadTimer.Inc(statedb.StorageReads.Milliseconds()) // Storage reads are complete, we can mark them
accountUpdateTimer.Inc(statedb.AccountUpdates.Milliseconds()) // Account updates are complete, we can mark them
storageUpdateTimer.Inc(statedb.StorageUpdates.Milliseconds()) // Storage updates are complete, we can mark them
snapshotAccountReadTimer.Inc(statedb.SnapshotAccountReads.Milliseconds()) // Account reads are complete, we can mark them
snapshotStorageReadTimer.Inc(statedb.SnapshotStorageReads.Milliseconds()) // Storage reads are complete, we can mark them
triehash := statedb.AccountHashes + statedb.StorageHashes // Save to not double count in validation
trieproc := statedb.SnapshotAccountReads + statedb.AccountReads + statedb.AccountUpdates
trieproc += statedb.SnapshotStorageReads + statedb.StorageReads + statedb.StorageUpdates
trieproc := statedb.SnapshotAccountReads + statedb.AccountReads
trieproc += statedb.SnapshotStorageReads + statedb.StorageReads
blockExecutionTimer.Inc((time.Since(substart) - trieproc - triehash).Milliseconds())
blockTrieOpsTimer.Inc((trieproc + triehash).Milliseconds())

// Validate the state using the default validator
substart = time.Now()
Expand All @@ -1212,9 +1209,15 @@ func (bc *BlockChain) insertBlock(block *types.Block, writes bool) error {
}

// Update the metrics touched during block validation
accountHashTimer.Inc(statedb.AccountHashes.Milliseconds()) // Account hashes are complete, we can mark them
storageHashTimer.Inc(statedb.StorageHashes.Milliseconds()) // Storage hashes are complete, we can mark them
blockStateValidationTimer.Inc((time.Since(substart) - (statedb.AccountHashes + statedb.StorageHashes - triehash)).Milliseconds())
accountUpdateTimer.Inc(statedb.AccountUpdates.Milliseconds()) // Account updates are complete, we can mark them
storageUpdateTimer.Inc(statedb.StorageUpdates.Milliseconds()) // Storage updates are complete, we can mark them
accountHashTimer.Inc(statedb.AccountHashes.Milliseconds()) // Account hashes are complete, we can mark them
storageHashTimer.Inc(statedb.StorageHashes.Milliseconds()) // Storage hashes are complete, we can mark them
newTriehash := (statedb.AccountHashes + statedb.StorageHashes - triehash)
blockStateValidationTimer.Inc((time.Since(substart) - newTriehash).Milliseconds())
trieproc += statedb.AccountUpdates + statedb.StorageUpdates
triehash += newTriehash
blockTrieOpsTimer.Inc((trieproc + triehash).Milliseconds())

// If [writes] are disabled, skip [writeBlockWithState] so that we do not write the block
// or the state trie to disk.
Expand Down

0 comments on commit 6bb9d01

Please sign in to comment.