mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 22:56:43 +00:00
Merge pull request #1406 from cffls/accurate_chain_execution
Make block execution timer more accurate
This commit is contained in:
commit
0d1b857a79
3 changed files with 10 additions and 2 deletions
|
|
@ -832,6 +832,7 @@ func (c *Bor) Finalize(chain consensus.ChainHeaderReader, header *types.Header,
|
||||||
}
|
}
|
||||||
|
|
||||||
if IsSprintStart(headerNumber, c.config.CalculateSprint(headerNumber)) {
|
if IsSprintStart(headerNumber, c.config.CalculateSprint(headerNumber)) {
|
||||||
|
start := time.Now()
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
cx := statefull.ChainContext{Chain: chain, Bor: c}
|
cx := statefull.ChainContext{Chain: chain, Bor: c}
|
||||||
// check and commit span
|
// check and commit span
|
||||||
|
|
@ -848,6 +849,8 @@ func (c *Bor) Finalize(chain consensus.ChainHeaderReader, header *types.Header,
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
state.BorConsensusTime = time.Since(start)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = c.changeContractCodeIfNeeded(headerNumber, state); err != nil {
|
if err = c.changeContractCodeIfNeeded(headerNumber, state); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,8 @@ var (
|
||||||
snapshotStorageReadTimer = metrics.NewRegisteredResettingTimer("chain/snapshot/storage/reads", nil)
|
snapshotStorageReadTimer = metrics.NewRegisteredResettingTimer("chain/snapshot/storage/reads", nil)
|
||||||
snapshotCommitTimer = metrics.NewRegisteredResettingTimer("chain/snapshot/commits", nil)
|
snapshotCommitTimer = metrics.NewRegisteredResettingTimer("chain/snapshot/commits", nil)
|
||||||
|
|
||||||
|
borConsensusTime = metrics.NewRegisteredTimer("chain/bor/consensus", nil)
|
||||||
|
|
||||||
blockImportTimer = metrics.NewRegisteredMeter("chain/imports", nil)
|
blockImportTimer = metrics.NewRegisteredMeter("chain/imports", nil)
|
||||||
triedbCommitTimer = metrics.NewRegisteredTimer("chain/triedb/commits", nil)
|
triedbCommitTimer = metrics.NewRegisteredTimer("chain/triedb/commits", nil)
|
||||||
|
|
||||||
|
|
@ -2355,7 +2357,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error)
|
||||||
bc.stateSyncFeed.Send(StateSyncEvent{Data: data})
|
bc.stateSyncFeed.Send(StateSyncEvent{Data: data})
|
||||||
}
|
}
|
||||||
// BOR
|
// BOR
|
||||||
ptime := time.Since(pstart) - vtime
|
ptime := time.Since(pstart) - vtime - statedb.BorConsensusTime
|
||||||
|
|
||||||
proctime := time.Since(start) // processing + validation
|
proctime := time.Since(start) // processing + validation
|
||||||
|
|
||||||
|
|
@ -2374,7 +2376,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error)
|
||||||
trieRead += statedb.SnapshotStorageReads + statedb.StorageReads // The time spent on storage read
|
trieRead += statedb.SnapshotStorageReads + statedb.StorageReads // The time spent on storage read
|
||||||
blockExecutionTimer.Update(ptime - trieRead) // The time spent on EVM processing
|
blockExecutionTimer.Update(ptime - trieRead) // The time spent on EVM processing
|
||||||
blockValidationTimer.Update(vtime - (triehash + trieUpdate)) // The time spent on block validation
|
blockValidationTimer.Update(vtime - (triehash + trieUpdate)) // The time spent on block validation
|
||||||
|
borConsensusTime.Update(statedb.BorConsensusTime) // The time spent on bor consensus (span + state sync)
|
||||||
// Write the block to the chain and get the status.
|
// Write the block to the chain and get the status.
|
||||||
var (
|
var (
|
||||||
wstart = time.Now()
|
wstart = time.Now()
|
||||||
|
|
|
||||||
|
|
@ -174,6 +174,9 @@ type StateDB struct {
|
||||||
SnapshotCommits time.Duration
|
SnapshotCommits time.Duration
|
||||||
TrieDBCommits time.Duration
|
TrieDBCommits time.Duration
|
||||||
|
|
||||||
|
// Bor metrics
|
||||||
|
BorConsensusTime time.Duration
|
||||||
|
|
||||||
AccountUpdated int
|
AccountUpdated int
|
||||||
StorageUpdated atomic.Int64
|
StorageUpdated atomic.Int64
|
||||||
AccountDeleted int
|
AccountDeleted int
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue