Skip to content

Commit e14a463

Browse files
committed
add timer for block preprocess state loading
1 parent faad758 commit e14a463

File tree

2 files changed

+27
-20
lines changed

2 files changed

+27
-20
lines changed

core/blockchain.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,11 @@ var (
100100
blockWriteTimer = metrics.NewRegisteredResettingTimer("chain/write", nil)
101101

102102
// BAL-specific timers
103-
blockPreprocessingTimer = metrics.NewRegisteredResettingTimer("chain/preprocess", nil)
104-
txExecutionTimer = metrics.NewRegisteredResettingTimer("chain/txexecution", nil)
105-
stateRootCalctimer = metrics.NewRegisteredResettingTimer("chain/rootcalculation", nil)
106-
blockPostprocessingTimer = metrics.NewRegisteredResettingTimer("chain/postprocess", nil)
103+
blockPreprocessingTimer = metrics.NewRegisteredResettingTimer("chain/preprocess", nil)
104+
blockPreprocessingLoadTimer = metrics.NewRegisteredResettingTimer("chain/preprocessload", nil)
105+
txExecutionTimer = metrics.NewRegisteredResettingTimer("chain/txexecution", nil)
106+
stateRootCalctimer = metrics.NewRegisteredResettingTimer("chain/rootcalculation", nil)
107+
blockPostprocessingTimer = metrics.NewRegisteredResettingTimer("chain/postprocess", nil)
107108

108109
blockReorgMeter = metrics.NewRegisteredMeter("chain/reorg/executes", nil)
109110
blockReorgAddMeter = metrics.NewRegisteredMeter("chain/reorg/add", nil)
@@ -2171,6 +2172,7 @@ func (bc *BlockChain) processBlock(parentRoot common.Hash, block *types.Block, s
21712172
var proctime time.Duration
21722173
if blockHadBAL {
21732174
blockPreprocessingTimer.Update(resWithMetrics.PreProcessTime)
2175+
blockPreprocessingLoadTimer.Update(resWithMetrics.PreProcessLoadTime)
21742176
txExecutionTimer.Update(resWithMetrics.ExecTime)
21752177
stateRootCalctimer.Update(resWithMetrics.RootCalcTime)
21762178
blockPostprocessingTimer.Update(resWithMetrics.PostProcessTime)

core/state_processor.go

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,12 @@ func NewStateProcessor(config *params.ChainConfig, chain *HeaderChain) *StatePro
5454
}
5555

5656
type ProcessResultWithMetrics struct {
57-
ProcessResult *ProcessResult
58-
PreProcessTime time.Duration
59-
PostProcessTime time.Duration
60-
RootCalcTime time.Duration
61-
ExecTime time.Duration
57+
ProcessResult *ProcessResult
58+
PreProcessTime time.Duration
59+
PreProcessLoadTime time.Duration
60+
PostProcessTime time.Duration
61+
RootCalcTime time.Duration
62+
ExecTime time.Duration
6263

6364
StateDiffCalcTime time.Duration // time it took to convert BAL into a set of state diffs
6465
TxStateDiffPrepTime time.Duration // time it took to convert state diffs into prestate statedbs for each tx
@@ -181,12 +182,13 @@ func (p *StateProcessor) ProcessWithAccessList(block *types.Block, statedb *stat
181182
rootCalcErrCh := make(chan error) // used for communicating if the state root calculation doesn't match the reported root
182183
pStart := time.Now()
183184
var (
184-
tPreprocess time.Duration // time to create a set of prestates for parallel transaction execution
185-
tVerifyStart time.Time
186-
tVerify time.Duration // time to compute and verify the state root
187-
tExecStart time.Time
188-
tExec time.Duration // time to execute block transactions
189-
tPostprocess time.Duration // time to perform post-transaction execution system calls and withdrawals.
185+
tPreprocess time.Duration // time to create a set of prestates for parallel transaction execution
186+
tVerifyStart time.Time
187+
tVerify time.Duration // time to compute and verify the state root
188+
tExecStart time.Time
189+
tExec time.Duration // time to execute block transactions
190+
tPostprocess time.Duration // time to perform post-transaction execution system calls and withdrawals.
191+
tPreprocessLoad time.Duration
190192
)
191193

192194
// called by resultHandler when all transactions have successfully executed.
@@ -315,11 +317,12 @@ func (p *StateProcessor) ProcessWithAccessList(block *types.Block, statedb *stat
315317
resCh <- &ProcessResultWithMetrics{ProcessResult: &ProcessResult{Error: err}}
316318
} else {
317319
resCh <- &ProcessResultWithMetrics{
318-
ProcessResult: execResults,
319-
PreProcessTime: tPreprocess,
320-
PostProcessTime: tPostprocess,
321-
ExecTime: tExec,
322-
RootCalcTime: tVerify,
320+
ProcessResult: execResults,
321+
PreProcessTime: tPreprocess,
322+
PreProcessLoadTime: tPreprocessLoad,
323+
PostProcessTime: tPostprocess,
324+
ExecTime: tExec,
325+
RootCalcTime: tVerify,
323326
}
324327
}
325328
}
@@ -422,7 +425,9 @@ func (p *StateProcessor) ProcessWithAccessList(block *types.Block, statedb *stat
422425
}
423426

424427
// instantiate a set of StateDBs to be used for executing each transaction in parallel
428+
tPreprocessLoadStart := time.Now()
425429
statedb.InstantiateWithStateDiffs(&totalDiff)
430+
tPreprocessLoad = time.Since(tPreprocessLoadStart)
426431
var txPrestates []*state.StateDB
427432
for range block.Transactions() {
428433
state := statedb.Copy()

0 commit comments

Comments
 (0)