From 030083e1a368725799b2a20b07d2f61d578778b5 Mon Sep 17 00:00:00 2001 From: Edd Robinson Date: Wed, 4 Sep 2019 17:38:13 +0100 Subject: [PATCH] perf(storage): optimistically check compactions --- tsdb/tsi1/partition.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tsdb/tsi1/partition.go b/tsdb/tsi1/partition.go index f6cfdc312b..32ad459a0a 100644 --- a/tsdb/tsi1/partition.go +++ b/tsdb/tsi1/partition.go @@ -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