This commit is contained in:
alex.sharov 2022-12-07 10:31:14 +07:00
parent 3cd34cc900
commit bf912d4eaa
2 changed files with 19 additions and 0 deletions

View File

@ -58,6 +58,22 @@ func WriteMap() bool {
return writeMap return writeMap
} }
var (
noSync bool
noSyncOnce sync.Once
)
func NoSync() bool {
noSyncOnce.Do(func() {
v, _ := os.LookupEnv("NO_SYNC")
if v == "true" {
noSync = true
log.Info("[Experiment]", "NO_SYNC", noSync)
}
})
return noSync
}
var ( var (
mergeTr int mergeTr int
mergeTrOnce sync.Once mergeTrOnce sync.Once

View File

@ -177,6 +177,9 @@ func (opts MdbxOpts) Open() (kv.RwDB, error) {
if dbg.WriteMap() { if dbg.WriteMap() {
opts = opts.WriteMap() //nolint opts = opts.WriteMap() //nolint
} }
if dbg.NoSync() {
opts = opts.Flags(func(u uint) uint { return u | mdbx.SafeNoSync }) //nolint
}
if dbg.MergeTr() > 0 { if dbg.MergeTr() > 0 {
opts = opts.WriteMergeThreshold(uint64(dbg.MergeTr() * 8192)) //nolint opts = opts.WriteMergeThreshold(uint64(dbg.MergeTr() * 8192)) //nolint
} }