app/vmselect/netstorage: properly pre-allocate space for sbs

This commit is contained in:
Aliaksandr Valialkin 2020-09-22 23:49:47 +03:00
parent 5c42965853
commit bed25e3c24

View File

@ -259,7 +259,8 @@ func (pts *packedTimeseries) Unpack(dst *Result, tr storage.TimeRange, fetchData
}
// Feed workers with work
upws := make([]*unpackWork, 0, 1+len(pts.brs)/unpackBatchSize)
brsLen := len(pts.brs)
upws := make([]*unpackWork, 0, 1+brsLen/unpackBatchSize)
upw := getUnpackWork()
upw.fetchData = fetchData
for _, br := range pts.brs {
@ -279,7 +280,7 @@ func (pts *packedTimeseries) Unpack(dst *Result, tr storage.TimeRange, fetchData
pts.brs = pts.brs[:0]
// Wait until work is complete
sbs := make([]*sortBlock, 0, len(pts.brs))
sbs := make([]*sortBlock, 0, brsLen)
var firstErr error
for _, upw := range upws {
if err := <-upw.doneCh; err != nil && firstErr == nil {