Merge pull request #11330 from shenjiangc/master

mvcc/kvstore: Optimize compaction, slove conflict for #11150
This commit is contained in:
Jingyi Hu 2019-11-04 20:56:01 -08:00 committed by GitHub
commit cbc1340af5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -272,15 +272,15 @@ func (s *store) updateCompactRev(rev int64) (<-chan struct{}, error) {
}
func (s *store) compact(trace *traceutil.Trace, rev int64) (<-chan struct{}, error) {
start := time.Now()
keep := s.kvindex.Compact(rev)
trace.Step("compact in-memory index tree")
ch := make(chan struct{})
var j = func(ctx context.Context) {
if ctx.Err() != nil {
s.compactBarrier(ctx, ch)
return
}
start := time.Now()
keep := s.kvindex.Compact(rev)
indexCompactionPauseMs.Observe(float64(time.Since(start) / time.Millisecond))
if !s.scheduleCompaction(rev, keep) {
s.compactBarrier(nil, ch)
return
@ -289,8 +289,6 @@ func (s *store) compact(trace *traceutil.Trace, rev int64) (<-chan struct{}, err
}
s.fifoSched.Schedule(j)
indexCompactionPauseMs.Observe(float64(time.Since(start) / time.Millisecond))
trace.Step("schedule compaction")
return ch, nil
}