Skip to content

Commit de10fd6

Browse files
committed
Fix a peformance regression due to uncertain compaction sleep interval
Signed-off-by: Benjamin Wang <[email protected]>
1 parent 075fb10 commit de10fd6

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

server/storage/mvcc/kvstore_compaction.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ func (s *store) scheduleCompaction(compactMainRev, prevCompactRev int64) (KeyVal
4040
binary.BigEndian.PutUint64(end, uint64(compactMainRev+1))
4141

4242
batchNum := s.cfg.CompactionBatchLimit
43-
batchTicker := time.NewTicker(s.cfg.CompactionSleepInterval)
44-
defer batchTicker.Stop()
4543
h := newKVHasher(prevCompactRev, compactMainRev, keep)
4644
last := make([]byte, 8+1+8)
4745
for {
@@ -91,7 +89,7 @@ func (s *store) scheduleCompaction(compactMainRev, prevCompactRev int64) (KeyVal
9189
dbCompactionPauseMs.Observe(float64(time.Since(start) / time.Millisecond))
9290

9391
select {
94-
case <-batchTicker.C:
92+
case <-time.After(s.cfg.CompactionSleepInterval):
9593
case <-s.stopc:
9694
return KeyValueHash{}, fmt.Errorf("interrupted due to stop signal")
9795
}

0 commit comments

Comments
 (0)