Skip to content

Commit

Permalink
Avoid sync in inmemory mode (#1190)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Ibrahim Jarif authored Jan 14, 2020
1 parent 2a90c66 commit 2698bfc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion value.go
Original file line number Diff line number Diff line change
Expand Up @@ -1315,7 +1315,7 @@ func (reqs requests) IncrRef() {
// if fid >= vlog.maxFid. In some cases such as replay(while opening db), it might be called with
// fid < vlog.maxFid. To sync irrespective of file id just call it with math.MaxUint32.
func (vlog *valueLog) sync(fid uint32) error {
if vlog.opt.SyncWrites {
if vlog.opt.SyncWrites || vlog.opt.InMemory {
return nil
}

Expand Down

0 comments on commit 2698bfc

Please sign in to comment.