mvcc: Optimize compaction for short commit pauses

release-3.5
Joe Betz 2019-08-14 00:09:47 -07:00 committed by Gyuho Lee
parent c7b106896f
commit d57bc6e724
1 changed files with 3 additions and 2 deletions

View File

@ -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
@ -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
}