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.

(cherry picked from commit 2698bfc)
  • Loading branch information
Ibrahim Jarif committed Mar 5, 2020
1 parent 6bc367f commit 3dc7f27
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion value.go
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 3dc7f27

Please sign in to comment.