From 0468cdf33e42085d63da857f9201040c9245ecda Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Tue, 22 Sep 2020 23:50:55 +0300 Subject: [PATCH] app/vmselect/netstorage: properly pre-allocate space for sbs --- app/vmselect/netstorage/netstorage.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/vmselect/netstorage/netstorage.go b/app/vmselect/netstorage/netstorage.go index e4ebc7ae5b..fc9c7f7bb2 100644 --- a/app/vmselect/netstorage/netstorage.go +++ b/app/vmselect/netstorage/netstorage.go @@ -264,7 +264,8 @@ func (pts *packedTimeseries) Unpack(tbf *tmpBlocksFile, dst *Result, tr storage. } // Feed workers with work - upws := make([]*unpackWork, 0, 1+len(pts.addrs)/unpackBatchSize) + addrsLen := len(pts.addrs) + upws := make([]*unpackWork, 0, 1+addrsLen/unpackBatchSize) upw := getUnpackWork() upw.tbf = tbf upw.fetchData = fetchData @@ -288,7 +289,7 @@ func (pts *packedTimeseries) Unpack(tbf *tmpBlocksFile, dst *Result, tr storage. pts.addrs = pts.addrs[:0] // Wait until work is complete - sbs := make([]*sortBlock, 0, len(pts.addrs)) + sbs := make([]*sortBlock, 0, addrsLen) var firstErr error for _, upw := range upws { if err := <-upw.doneCh; err != nil && firstErr == nil {