diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 239b20f6b..c4315173a 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -384,7 +384,7 @@ var ( DBReadConcurrencyFlag = cli.IntFlag{ Name: "db.read.concurrency", Usage: "Does limit amount of parallel db reads. Default: equal to GOMAXPROCS (or number of CPU)", - Value: cmp.Max(10, runtime.GOMAXPROCS(-1)*2), + Value: cmp.Max(10, runtime.GOMAXPROCS(-1)*4), } RpcAccessListFlag = cli.StringFlag{ Name: "rpc.accessList", diff --git a/node/node.go b/node/node.go index 611a7b25a..4d6237508 100644 --- a/node/node.go +++ b/node/node.go @@ -30,6 +30,7 @@ import ( "github.com/c2h5oh/datasize" "github.com/ledgerwatch/erigon/node/nodecfg" "github.com/ledgerwatch/erigon/params" + "golang.org/x/sync/semaphore" "github.com/gofrs/flock" "github.com/ledgerwatch/erigon-lib/kv" @@ -319,7 +320,12 @@ func OpenDatabase(config *nodecfg.Config, logger log.Logger, label kv.Label) (kv var openFunc func(exclusive bool) (kv.RwDB, error) log.Info("Opening Database", "label", name, "path", dbPath) openFunc = func(exclusive bool) (kv.RwDB, error) { - opts := mdbx.NewMDBX(logger).Path(dbPath).Label(label).DBVerbosity(config.DatabaseVerbosity) + roTxLimit := int64(16) + if config.Http.DBReadConcurrency > 0 { + roTxLimit = int64(config.Http.DBReadConcurrency) + } + roTxsLimiter := semaphore.NewWeighted(roTxLimit) // 1 less than max to allow unlocking to happen + opts := mdbx.NewMDBX(logger).Path(dbPath).Label(label).DBVerbosity(config.DatabaseVerbosity).RoTxsLimiter(roTxsLimiter) if exclusive { opts = opts.Exclusive() }