From 53ea6d63901b96a13bb79ff598c96af4a979adce Mon Sep 17 00:00:00 2001 From: Ganesh Vernekar <15064823+codesome@users.noreply.github.com> Date: Thu, 3 Oct 2019 15:21:39 +0530 Subject: [PATCH] Allocate the shards only once while reading WAL (#6093) Signed-off-by: Ganesh Vernekar --- tsdb/head.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsdb/head.go b/tsdb/head.go index 9fbe07c9b..495532cdb 100644 --- a/tsdb/head.go +++ b/tsdb/head.go @@ -368,6 +368,7 @@ func (h *Head) loadWAL(r *wal.Reader, multiRef map[uint64]uint64) (err error) { samples []record.RefSample tstones []tombstones.Stone allStones = tombstones.NewMemTombstones() + shards = make([][]record.RefSample, n) ) defer func() { if err := allStones.Close(); err != nil { @@ -421,7 +422,6 @@ func (h *Head) loadWAL(r *wal.Reader, multiRef map[uint64]uint64) (err error) { if len(samples) < m { m = len(samples) } - shards := make([][]record.RefSample, n) for i := 0; i < n; i++ { var buf []record.RefSample select {