Revert "Revert "apply --db.read.concurrency flag value when open embedded db "" (#5559)

This commit is contained in:
Alex Sharov 2022-09-28 13:48:43 +07:00 committed by GitHub
parent e4ad73bcb4
commit 3c5625c72a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -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",

View File

@ -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()
}