This commit is contained in:
alex.sharov 2022-11-16 09:43:56 +03:00
parent 44f909767d
commit bfda9bc731
2 changed files with 26 additions and 1 deletions

View File

@ -22,6 +22,28 @@ func WriteMap() bool {
return writeMap
}
var (
mergeTr int
mergeTrOnce sync.Once
)
func MergeTr() int {
mergeTrOnce.Do(func() {
v, _ := os.LookupEnv("MERGE_THRESHOLD")
if v != "" {
i, err := strconv.Atoi(v)
if err != nil {
panic(err)
}
if i < 0 || i > 4 {
panic(i)
}
mergeTr = i
}
})
return mergeTr
}
var (
mdbxReaadahead bool
mdbxReaadaheadOnce sync.Once

View File

@ -340,7 +340,10 @@ func OpenDatabase(config *nodecfg.Config, logger log.Logger, label kv.Label) (kv
opts = opts.GrowthStep(16 * datasize.MB)
}
if debug.WriteMap() {
opts = opts.WriteMap().WriteMergeThreshold(1 * 8192)
opts = opts.WriteMap()
}
if debug.MergeTr() > 0 {
opts = opts.WriteMergeThreshold(uint64(debug.MergeTr() * 8192))
}
if debug.MdbxReadAhead() {
opts = opts.Flags(func(u uint) uint {