Skip to content

Commit

Permalink
fix: use ParallelTxNum config and uber automaxprocs
Browse files Browse the repository at this point in the history
  • Loading branch information
welkin22 committed Oct 23, 2024
1 parent c5f1c9e commit accb269
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -2030,6 +2030,10 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
cfg.ParallelTxUnorderedMerge = ctx.Bool(ParallelTxUnorderedMergeFlag.Name)
}

if ctx.IsSet(ParallelTxNumFlag.Name) {
cfg.ParallelTxNum = ctx.Int(ParallelTxNumFlag.Name)
}

if ctx.IsSet(ParallelTxDAGFlag.Name) {
cfg.EnableParallelTxDAG = ctx.Bool(ParallelTxDAGFlag.Name)
}
Expand Down
11 changes: 7 additions & 4 deletions core/parallel_state_scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
_ "go.uber.org/automaxprocs"
)

var runner chan func()

func init() {
cpuNum := runtime.NumCPU()
runner = make(chan func(), cpuNum)
for i := 0; i < cpuNum; i++ {
func initParallelRunner(targetNum int) {
if targetNum == 0 {
targetNum = runtime.NumCPU()
}
runner = make(chan func(), targetNum)
for i := 0; i < targetNum; i++ {
go func() {
for f := range runner {
f()
Expand Down
1 change: 1 addition & 0 deletions core/pevm_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func newPEVMProcessor(config *params.ChainConfig, bc *BlockChain, engine consens
StateProcessor: *NewStateProcessor(config, bc, engine),
unorderedMerge: bc.vmConfig.EnableParallelUnorderedMerge,
}
initParallelRunner(bc.vmConfig.ParallelTxNum)
log.Info("Parallel execution mode is enabled", "Parallel Num", ParallelNum(),
"CPUNum", runtime.NumCPU(), "unorderedMerge", processor.unorderedMerge)
return processor
Expand Down

0 comments on commit accb269

Please sign in to comment.