perf(storage): optimistically check compactions

pull/14925/head
Edd Robinson 2019-09-04 17:38:13 +01:00
parent af5996fe45
commit 030083e1a3
1 changed files with 5 additions and 2 deletions

View File

@ -920,9 +920,12 @@ func (p *Partition) CurrentCompactionN() int {
// Wait will block until all compactions are finished.
// Must only be called while they are disabled.
func (p *Partition) Wait() {
ticker := time.NewTicker(100 * time.Millisecond)
defer ticker.Stop()
if p.CurrentCompactionN() == 0 { // Is it possible to immediately return?
return
}
ticker := time.NewTicker(10 * time.Millisecond)
defer ticker.Stop()
for range ticker.C {
if p.CurrentCompactionN() == 0 {
return