From bfda9bc731dd6a3cf5a369a0d2f6ed5cd97ab3f9 Mon Sep 17 00:00:00 2001 From: "alex.sharov" Date: Wed, 16 Nov 2022 09:43:56 +0300 Subject: [PATCH] save --- common/debug/experiments.go | 22 ++++++++++++++++++++++ node/node.go | 5 ++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/common/debug/experiments.go b/common/debug/experiments.go index 5f2a87f5c..a0306c649 100644 --- a/common/debug/experiments.go +++ b/common/debug/experiments.go @@ -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 diff --git a/node/node.go b/node/node.go index 99fc14349..4a0860fa9 100644 --- a/node/node.go +++ b/node/node.go @@ -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 {