diff --git a/core/blockchain.go b/core/blockchain.go index 29ad6aada757..2fe8f9a836fe 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -1947,18 +1947,6 @@ func (bc *BlockChain) processBlock(block *types.Block, statedb *state.StateDB, s } proctime := time.Since(start) // processing + validation - // Update the metrics touched during block processing and validation - accountReadTimer.Update(statedb.AccountReads) // Account reads are complete(in processing) - storageReadTimer.Update(statedb.StorageReads) // Storage reads are complete(in processing) - accountUpdateTimer.Update(statedb.AccountUpdates) // Account updates are complete(in validation) - storageUpdateTimer.Update(statedb.StorageUpdates) // Storage updates are complete(in validation) - accountHashTimer.Update(statedb.AccountHashes) // Account hashes are complete(in validation) - triehash := statedb.AccountHashes // The time spent on tries hashing - trieUpdate := statedb.AccountUpdates + statedb.StorageUpdates // The time spent on tries update - trieRead := statedb.AccountReads + statedb.StorageReads // The time spent on account read and storage read - blockExecutionTimer.Update(ptime - trieRead) // The time spent on EVM processing - blockValidationTimer.Update(vtime - (triehash + trieUpdate)) // The time spent on block validation - // Write the block to the chain and get the status. var ( wstart = time.Now() @@ -1973,6 +1961,18 @@ func (bc *BlockChain) processBlock(block *types.Block, statedb *state.StateDB, s if err != nil { return nil, err } + // Update the metrics touched during block processing and validation + accountReadTimer.Update(statedb.AccountReads) // Account reads are complete(in processing) + storageReadTimer.Update(statedb.StorageReads) // Storage reads are complete(in processing) + accountUpdateTimer.Update(statedb.AccountUpdates) // Account updates are complete(in validation) + storageUpdateTimer.Update(statedb.StorageUpdates) // Storage updates are complete(in validation) + accountHashTimer.Update(statedb.AccountHashes) // Account hashes are complete(in validation) + triehash := statedb.AccountHashes // The time spent on account trie hashing + trieUpdate := statedb.AccountUpdates + statedb.StorageUpdates // The time spent on account trie update + storage tries update and hashing + trieRead := statedb.AccountReads + statedb.StorageReads // The time spent on account read and storage read + blockExecutionTimer.Update(ptime - trieRead) // The time spent on EVM processing + blockValidationTimer.Update(vtime - (triehash + trieUpdate)) // The time spent on block validation + // Update the metrics touched during block commit accountCommitTimer.Update(statedb.AccountCommits) // Account commits are complete, we can mark them storageCommitTimer.Update(statedb.StorageCommits) // Storage commits are complete, we can mark them diff --git a/core/state/metrics.go b/core/state/metrics.go index 870b71492b82..7447e44dfd1e 100644 --- a/core/state/metrics.go +++ b/core/state/metrics.go @@ -33,9 +33,4 @@ var ( slotDeletionTimer = metrics.NewRegisteredResettingTimer("state/delete/storage/timer", nil) slotDeletionCount = metrics.NewRegisteredMeter("state/delete/storage/slot", nil) slotDeletionSize = metrics.NewRegisteredMeter("state/delete/storage/size", nil) - - trieAccountReadTimer = metrics.NewRegisteredResettingTimer("state/trie/account/reads", nil) - trieStorageReadTimer = metrics.NewRegisteredResettingTimer("state/trie/storage/reads", nil) - snapshotAccountReadTimer = metrics.NewRegisteredResettingTimer("state/snapshot/account/reads", nil) - snapshotStorageReadTimer = metrics.NewRegisteredResettingTimer("state/snapshot/storage/reads", nil) ) diff --git a/core/state/reader.go b/core/state/reader.go index c3e5f9e8edf2..f4526308fb8a 100644 --- a/core/state/reader.go +++ b/core/state/reader.go @@ -88,7 +88,6 @@ func newStateReader(root common.Hash, snaps *snapshot.Tree) (*stateReader, error func (r *stateReader) Account(addr common.Address) (*types.StateAccount, error) { defer func(start time.Time) { r.accountTime += time.Since(start) - snapshotAccountReadTimer.UpdateSince(start) }(time.Now()) ret, err := r.snap.Account(crypto.HashData(r.buff, addr.Bytes())) @@ -123,7 +122,6 @@ func (r *stateReader) Account(addr common.Address) (*types.StateAccount, error) func (r *stateReader) Storage(addr common.Address, key common.Hash) (common.Hash, error) { defer func(start time.Time) { r.storageTime += time.Since(start) - snapshotStorageReadTimer.UpdateSince(start) }(time.Now()) addrHash := crypto.HashData(r.buff, addr.Bytes()) @@ -207,7 +205,6 @@ func newTrieReader(root common.Hash, db *triedb.Database, cache *utils.PointCach func (r *trieReader) Account(addr common.Address) (*types.StateAccount, error) { defer func(start time.Time) { r.accountTime += time.Since(start) - trieAccountReadTimer.UpdateSince(start) }(time.Now()) account, err := r.mainTrie.GetAccount(addr) @@ -230,7 +227,6 @@ func (r *trieReader) Account(addr common.Address) (*types.StateAccount, error) { func (r *trieReader) Storage(addr common.Address, key common.Hash) (common.Hash, error) { defer func(start time.Time) { r.storageTime += time.Since(start) - trieStorageReadTimer.UpdateSince(start) }(time.Now()) var ( diff --git a/core/state/statedb.go b/core/state/statedb.go index 55bf7feadef0..e835be620627 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -1310,7 +1310,7 @@ func (s *StateDB) commitAndFlush(block uint64, deleteEmptyObjects bool) (*stateU // Submit the statistics of reader to metric system and reset it with new root aTime, sTime := s.reader.Stats() s.AccountReads += aTime - s.AccountReads += sTime + s.StorageReads += sTime s.reader, _ = s.db.Reader(s.originalRoot) return ret, err