Skip to content

Commit

Permalink
mvcc: Optimize compaction for short commit pauses
Browse files Browse the repository at this point in the history
  • Loading branch information
jpbetz committed Aug 14, 2019
1 parent fd0d43d commit 821e98c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mvcc/kvstore_compaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (s *store) scheduleCompaction(compactMainRev int64, keep map[revision]struc
end := make([]byte, 8)
binary.BigEndian.PutUint64(end, uint64(compactMainRev+1))

batchsize := int64(10000)
batchsize := int64(1000)
last := make([]byte, 8+1+8)
for {
var rev revision
Expand Down Expand Up @@ -68,10 +68,11 @@ func (s *store) scheduleCompaction(compactMainRev int64, keep map[revision]struc
// update last
revToBytes(revision{main: rev.main, sub: rev.sub + 1}, last)
tx.Unlock()
s.b.ForceCommit()
dbCompactionPauseMs.Observe(float64(time.Since(start) / time.Millisecond))

select {
case <-time.After(100 * time.Millisecond):
case <-time.After(10 * time.Millisecond):
case <-s.stopc:
return false
}
Expand Down

0 comments on commit 821e98c

Please sign in to comment.