add --bal.prefetchworkers flag to parameterize state loading concurrency when executing with BALs

This commit is contained in:
Jared Wasinger 2026-05-06 13:31:26 -04:00
parent 5c101bba03
commit 10314a1fe1
3 changed files with 13 additions and 1 deletions

View file

@ -159,6 +159,7 @@ var (
utils.BeaconCheckpointFlag, utils.BeaconCheckpointFlag,
utils.BeaconCheckpointFileFlag, utils.BeaconCheckpointFileFlag,
utils.LogSlowBlockFlag, utils.LogSlowBlockFlag,
utils.PrefetchWorkersFlag,
}, utils.NetworkFlags, utils.DatabaseFlags) }, utils.NetworkFlags, utils.DatabaseFlags)
rpcFlags = []cli.Flag{ rpcFlags = []cli.Flag{

View file

@ -28,6 +28,7 @@ import (
"net/http" "net/http"
"os" "os"
"path/filepath" "path/filepath"
"runtime"
godebug "runtime/debug" godebug "runtime/debug"
"strconv" "strconv"
"strings" "strings"
@ -713,6 +714,13 @@ var (
Category: flags.MiscCategory, Category: flags.MiscCategory,
} }
PrefetchWorkersFlag = &cli.UintFlag{
Name: "bal.prefetchworkers",
Usage: "The number of concurrent state loading tasks to perform when prefetching BAL state. Default to the number of cpus",
Value: uint(runtime.NumCPU()),
Category: flags.MiscCategory,
}
// RPC settings // RPC settings
IPCDisabledFlag = &cli.BoolFlag{ IPCDisabledFlag = &cli.BoolFlag{
Name: "ipcdisable", Name: "ipcdisable",
@ -2459,6 +2467,7 @@ func MakeChain(ctx *cli.Context, stack *node.Node, readonly bool) (*core.BlockCh
TrienodeHistory: ctx.Int64(TrienodeHistoryFlag.Name), TrienodeHistory: ctx.Int64(TrienodeHistoryFlag.Name),
NodeFullValueCheckpoint: uint32(ctx.Uint(TrienodeHistoryFullValueCheckpointFlag.Name)), NodeFullValueCheckpoint: uint32(ctx.Uint(TrienodeHistoryFullValueCheckpointFlag.Name)),
PrefetchWorkers: int(ctx.Uint(PrefetchWorkersFlag.Name)),
// Disable transaction indexing/unindexing. // Disable transaction indexing/unindexing.
TxLookupLimit: -1, TxLookupLimit: -1,

View file

@ -211,6 +211,8 @@ type BlockChainConfig struct {
Overrides *ChainOverrides // Optional chain config overrides Overrides *ChainOverrides // Optional chain config overrides
VmConfig vm.Config // Config options for the EVM Interpreter VmConfig vm.Config // Config options for the EVM Interpreter
PrefetchWorkers int // number of concurrent go-routines for BAL state prefetching
// TxLookupLimit specifies the maximum number of blocks from head for which // TxLookupLimit specifies the maximum number of blocks from head for which
// transaction hashes will be indexed. // transaction hashes will be indexed.
// //
@ -597,7 +599,7 @@ func (bc *BlockChain) processBlockWithAccessList(parentRoot common.Hash, block *
useAsyncReads := bc.cfg.BALExecutionMode != bal.BALExecutionNoBatchIO useAsyncReads := bc.cfg.BALExecutionMode != bal.BALExecutionNoBatchIO
al := block.AccessList() // TODO: make the return of this method not be a pointer al := block.AccessList() // TODO: make the return of this method not be a pointer
accessListReader := bal.NewAccessListReader(*al) accessListReader := bal.NewAccessListReader(*al)
prefetchReader, err := sdb.ReaderEIP7928(parentRoot, accessListReader.StorageKeys(useAsyncReads), runtime.NumCPU()) prefetchReader, err := sdb.ReaderEIP7928(parentRoot, accessListReader.StorageKeys(useAsyncReads), bc.cfg.PrefetchWorkers)
if err != nil { if err != nil {
return nil, err return nil, err
} }