Skip to content

Commit 2698bfc

Browse files
author
Ibrahim Jarif
authored
Avoid sync in inmemory mode (#1190)
This makes db.Sync() no-op when badger is running in in-memory mode. The previous code would unnecessarily load up an atomic and acquire locks.
1 parent 2a90c66 commit 2698bfc

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

value.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1315,7 +1315,7 @@ func (reqs requests) IncrRef() {
13151315
// if fid >= vlog.maxFid. In some cases such as replay(while opening db), it might be called with
13161316
// fid < vlog.maxFid. To sync irrespective of file id just call it with math.MaxUint32.
13171317
func (vlog *valueLog) sync(fid uint32) error {
1318-
if vlog.opt.SyncWrites {
1318+
if vlog.opt.SyncWrites || vlog.opt.InMemory {
13191319
return nil
13201320
}
13211321

0 commit comments

Comments
 (0)