Skip to content

Commit

Permalink
fix valueLog doRunGC to use consistent units (#725)
Browse files Browse the repository at this point in the history
this version introduces sizeWindowM to use when comparing against
other values already in MB
  • Loading branch information
mschoch authored and manishrjain committed Feb 28, 2019
1 parent 8115aed commit 68856da
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions value.go
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,7 @@ func (vlog *valueLog) doRunGC(lf *logFile, discardRatio float64, tr trace.Trace)

// Set up the sampling window sizes.
sizeWindow := float64(fi.Size()) * 0.1 // 10% of the file as window.
sizeWindowM := sizeWindow / (1 << 20) // in MBs.
countWindow := int(float64(vlog.opt.ValueLogMaxEntries) * 0.01) // 1% of num entries.
tr.LazyPrintf("Size window: %5.2f. Count window: %d.", sizeWindow, countWindow)

Expand Down Expand Up @@ -1185,7 +1186,7 @@ func (vlog *valueLog) doRunGC(lf *logFile, discardRatio float64, tr trace.Trace)
tr.LazyPrintf("Stopping sampling after %d entries.", countWindow)
return errStop
}
if r.total > sizeWindow {
if r.total > sizeWindowM {
tr.LazyPrintf("Stopping sampling after reaching window size.")
return errStop
}
Expand Down Expand Up @@ -1250,7 +1251,7 @@ func (vlog *valueLog) doRunGC(lf *logFile, discardRatio float64, tr trace.Trace)

// If we couldn't sample at least a 1000 KV pairs or at least 75% of the window size,
// and what we can discard is below the threshold, we should skip the rewrite.
if (r.count < countWindow && r.total < sizeWindow*0.75) || r.discard < discardRatio*r.total {
if (r.count < countWindow && r.total < sizeWindowM*0.75) || r.discard < discardRatio*r.total {
tr.LazyPrintf("Skipping GC on fid: %d", lf.fid)
return ErrNoRewrite
}
Expand Down

0 comments on commit 68856da

Please sign in to comment.