Skip to content

Commit

Permalink
Revert "feat: disable parallel when txs count is low (bnb-chain#226)"
Browse files Browse the repository at this point in the history
This reverts commit 70107bf
  • Loading branch information
welkin22 committed Dec 12, 2024
1 parent ea0cf3f commit 1bb27e9
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 26 deletions.
1 change: 0 additions & 1 deletion cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ var (
utils.ParallelTxUnorderedMergeFlag,
utils.ParallelTxParallelMergeFlag,
utils.ParallelTxNumFlag,
utils.ParallelThresholdFlag,
utils.ParallelTxDAGFlag,
utils.ParallelTxDAGFileFlag,
utils.ParallelTxDAGSenderPrivFlag,
Expand Down
10 changes: 0 additions & 10 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -1123,12 +1123,6 @@ Please note that --` + MetricsHTTPFlag.Name + ` must be set to start the server.
Category: flags.VMCategory,
}

ParallelThresholdFlag = &cli.IntFlag{
Name: "parallel.threshold",
Usage: "Threshold of transaction count to trigger parallel execution, only valid in parallel mode (runtime calculated, no fixed default value)",
Category: flags.VMCategory,
}

ParallelTxDAGFlag = &cli.BoolFlag{
Name: "parallel.txdag",
Usage: "Enable the experimental parallel TxDAG generation, only valid in full sync mode (default = false)",
Expand Down Expand Up @@ -2055,10 +2049,6 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
cfg.ParallelTxNum = ctx.Int(ParallelTxNumFlag.Name)
}

if ctx.IsSet(ParallelThresholdFlag.Name) {
cfg.ParallelThreshold = ctx.Int(ParallelThresholdFlag.Name)
}

if ctx.IsSet(ParallelTxDAGFlag.Name) {
cfg.EnableParallelTxDAG = ctx.Bool(ParallelTxDAGFlag.Name)
}
Expand Down
8 changes: 1 addition & 7 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,6 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis
log.Info("Parallel V2 enabled", "parallelNum", ParallelNum())
} else {
bc.processor = NewStateProcessor(chainConfig, bc, engine)
bc.serialProcessor = bc.processor
}
// Start future block processor.
bc.wg.Add(1)
Expand Down Expand Up @@ -2015,14 +2014,9 @@ 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 || bc.vmConfig.EnableTxParallelMerge)
useSerialProcessor := invalidParallelConfig || lowTxsNum || !bc.vmConfig.EnableParallelExec

// Process block using the parent state as reference point
pstart = time.Now()

if useSerialProcessor {
if bc.vmConfig.TxDAG == nil && (bc.vmConfig.EnableParallelUnorderedMerge || bc.vmConfig.EnableTxParallelMerge) {
receipts, logs, usedGas, err = bc.serialProcessor.Process(block, statedb, bc.vmConfig)
blockProcessedInParallel = false
} else {
Expand Down
6 changes: 1 addition & 5 deletions core/pevm_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,8 @@ func newPEVMProcessor(config *params.ChainConfig, bc *BlockChain, engine consens
parallelMerge: bc.vmConfig.EnableTxParallelMerge,
}
initParallelRunner(bc.vmConfig.ParallelTxNum)
if bc.vmConfig.ParallelThreshold == 0 {
bc.vmConfig.ParallelThreshold = ParallelNum()
}
log.Info("Parallel execution mode is enabled", "Parallel Num", ParallelNum(),
"CPUNum", runtime.GOMAXPROCS(0), "unorderedMerge", processor.unorderedMerge,
"parallel threshold", bc.vmConfig.ParallelThreshold)
"CPUNum", runtime.GOMAXPROCS(0), "unorderedMerge", processor.unorderedMerge)
return processor
}

Expand Down
1 change: 0 additions & 1 deletion core/vm/interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ type Config struct {
ExtraEips []int // Additional EIPS that are to be enabled
EnableParallelExec bool // Whether to execute transaction in parallel mode when do full sync
ParallelTxNum int // Number of slot for transaction execution
ParallelThreshold int // Threshold of transactions number to trigger parallel process
OptimismPrecompileOverrides PrecompileOverrides // Precompile overrides for Optimism
EnableOpcodeOptimizations bool // Enable opcode optimization
TxDAG types.TxDAG
Expand Down
1 change: 0 additions & 1 deletion eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
EnableParallelUnorderedMerge: config.ParallelTxUnorderedMerge,
EnableTxParallelMerge: config.ParallelTxParallelMerge,
ParallelTxNum: config.ParallelTxNum,
ParallelThreshold: config.ParallelThreshold,
EnableOpcodeOptimizations: config.EnableOpcodeOptimizing,
}
cacheConfig = &core.CacheConfig{
Expand Down
2 changes: 1 addition & 1 deletion eth/ethconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,12 @@ type Config struct {

ParallelTxMode bool // Whether to execute transaction in parallel mode when do full sync
ParallelTxNum int // Number of slot for transaction execution
ParallelThreshold int // threshold to trigger parallel execution
EnableOpcodeOptimizing bool
EnableParallelTxDAG bool
ParallelTxDAGFile string
ParallelTxUnorderedMerge bool // Whether to enable unordered merge in parallel mode
ParallelTxParallelMerge bool

}

// CreateConsensusEngine creates a consensus engine for the given chain config.
Expand Down

0 comments on commit 1bb27e9

Please sign in to comment.