From 30ed33fae0767a9c074076eebf6d6289aa08179e Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Mon, 9 Jan 2023 22:51:14 -0800 Subject: [PATCH] app/vmselect/promql: pre-allocate memory for values to be merged in mergeTimeseries() This should reduce the number of memory re-allocations --- app/vmselect/promql/rollup_result_cache.go | 1 + 1 file changed, 1 insertion(+) diff --git a/app/vmselect/promql/rollup_result_cache.go b/app/vmselect/promql/rollup_result_cache.go index 6aabd4aa6..201c18f4f 100644 --- a/app/vmselect/promql/rollup_result_cache.go +++ b/app/vmselect/promql/rollup_result_cache.go @@ -525,6 +525,7 @@ func mergeTimeseries(a, b []*timeseries, bStart int64, ec *EvalConfig) []*timese var tmp timeseries tmp.denyReuse = true tmp.Timestamps = sharedTimestamps + tmp.Values = make([]float64, 0, len(tmp.Timestamps)) tmp.MetricName.MoveFrom(&tsA.MetricName) tmp.Values = append(tmp.Values, tsA.Values...)