From 542b9ecdbd758009d52402f6a486d1237a6647b7 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Sun, 12 Jun 2022 07:24:11 +0100 Subject: [PATCH] tsdb: reduce sleep time when reading WAL (#10859) The code sleeps for a short time to allow goroutines to finish, however it seems the duration can be reduced a lot, speeding up the reading process. I checked using some WAL data from production, and the queue is almost always empty at the time we enter `waitForIdle()` so there is no danger of spinning in the tight loop. Signed-off-by: Bryan Boreham --- tsdb/head_wal.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsdb/head_wal.go b/tsdb/head_wal.go index 6f2fd6eaa..a8232ff7d 100644 --- a/tsdb/head_wal.go +++ b/tsdb/head_wal.go @@ -438,7 +438,7 @@ func (wp *walSubsetProcessor) waitUntilIdle() { } wp.input <- []record.RefSample{} for len(wp.input) != 0 { - time.Sleep(1 * time.Millisecond) + time.Sleep(10 * time.Microsecond) select { case <-wp.output: // Allow output side to drain to avoid deadlock. default: