Skip to content

Commit

Permalink
feat: disable parallel when txs count is low
Browse files Browse the repository at this point in the history
  • Loading branch information
sunny2022da committed Nov 19, 2024
1 parent 9ca5adc commit 1edced8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -1936,9 +1936,15 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error)

statedb.SetExpectedStateRoot(block.Root())

// Decide the enabling of parallelExec
invalidParallelConfig := bc.vmConfig.TxDAG == nil && bc.vmConfig.EnableParallelUnorderedMerge
lowTxsNum := bc.vmConfig.ParallelTxNum < block.Transactions().Len()
useSerialProcessor := invalidParallelConfig || lowTxsNum || !bc.vmConfig.EnableParallelExec

// Process block using the parent state as reference point
pstart = time.Now()
if bc.vmConfig.TxDAG == nil && bc.vmConfig.EnableParallelUnorderedMerge {

if useSerialProcessor {
receipts, logs, usedGas, err = bc.serialProcessor.Process(block, statedb, bc.vmConfig)
} else {
receipts, logs, usedGas, err = bc.processor.Process(block, statedb, bc.vmConfig)
Expand Down

0 comments on commit 1edced8

Please sign in to comment.