mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
core: attempt at alternative tx-level prefetcher
This commit is contained in:
parent
9be2e010c1
commit
f92418a580
2 changed files with 16 additions and 24 deletions
|
|
@ -1793,21 +1793,19 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error)
|
||||||
// transactions and probabilistically some of the account/storage trie nodes.
|
// transactions and probabilistically some of the account/storage trie nodes.
|
||||||
var followupInterrupt atomic.Bool
|
var followupInterrupt atomic.Bool
|
||||||
if !bc.cacheConfig.TrieCleanNoPrefetch {
|
if !bc.cacheConfig.TrieCleanNoPrefetch {
|
||||||
if followup, err := it.peek(); followup != nil && err == nil {
|
followup := block
|
||||||
throwaway, _ := state.New(parent.Root, bc.statedb)
|
throwaway, _ := state.New(parent.Root, bc.statedb)
|
||||||
|
go func(start time.Time, followup *types.Block, throwaway *state.StateDB) {
|
||||||
|
// Disable tracing for prefetcher executions.
|
||||||
|
vmCfg := bc.vmConfig
|
||||||
|
vmCfg.Tracer = nil
|
||||||
|
bc.prefetcher.Prefetch(followup, throwaway, vmCfg, &followupInterrupt)
|
||||||
|
|
||||||
go func(start time.Time, followup *types.Block, throwaway *state.StateDB) {
|
blockPrefetchExecuteTimer.Update(time.Since(start))
|
||||||
// Disable tracing for prefetcher executions.
|
if followupInterrupt.Load() {
|
||||||
vmCfg := bc.vmConfig
|
blockPrefetchInterruptMeter.Mark(1)
|
||||||
vmCfg.Tracer = nil
|
}
|
||||||
bc.prefetcher.Prefetch(followup, throwaway, vmCfg, &followupInterrupt)
|
}(time.Now(), followup, throwaway)
|
||||||
|
|
||||||
blockPrefetchExecuteTimer.Update(time.Since(start))
|
|
||||||
if followupInterrupt.Load() {
|
|
||||||
blockPrefetchInterruptMeter.Mark(1)
|
|
||||||
}
|
|
||||||
}(time.Now(), followup, throwaway)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The traced section of block import.
|
// The traced section of block import.
|
||||||
|
|
|
||||||
|
|
@ -53,8 +53,10 @@ func (p *statePrefetcher) Prefetch(block *types.Block, statedb *state.StateDB, c
|
||||||
signer = types.MakeSigner(p.config, header.Number, header.Time)
|
signer = types.MakeSigner(p.config, header.Number, header.Time)
|
||||||
)
|
)
|
||||||
// Iterate over and process the individual transactions
|
// Iterate over and process the individual transactions
|
||||||
byzantium := p.config.IsByzantium(block.Number())
|
txs := block.Transactions()
|
||||||
for i, tx := range block.Transactions() {
|
// Skip the first third of transactions, prefetch the latter two thirds of the transactions
|
||||||
|
for i := (len(txs) * 2) / 3; i < len(txs); i++ {
|
||||||
|
tx := txs[i]
|
||||||
// If block precaching was interrupted, abort
|
// If block precaching was interrupted, abort
|
||||||
if interrupt != nil && interrupt.Load() {
|
if interrupt != nil && interrupt.Load() {
|
||||||
return
|
return
|
||||||
|
|
@ -68,14 +70,6 @@ func (p *statePrefetcher) Prefetch(block *types.Block, statedb *state.StateDB, c
|
||||||
if err := precacheTransaction(msg, p.config, gaspool, statedb, header, evm); err != nil {
|
if err := precacheTransaction(msg, p.config, gaspool, statedb, header, evm); err != nil {
|
||||||
return // Ugh, something went horribly wrong, bail out
|
return // Ugh, something went horribly wrong, bail out
|
||||||
}
|
}
|
||||||
// If we're pre-byzantium, pre-load trie nodes for the intermediate root
|
|
||||||
if !byzantium {
|
|
||||||
statedb.IntermediateRoot(true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// If were post-byzantium, pre-load trie nodes for the final root hash
|
|
||||||
if byzantium {
|
|
||||||
statedb.IntermediateRoot(true)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue