From 562d6bca08d2c5c49d73dd1a94cf888a03a76bd4 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Mon, 9 Jan 2023 22:15:24 -0800 Subject: [PATCH] app/vmselect/promql: intern output series names during normal aggregation --- app/vmselect/promql/aggr.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/vmselect/promql/aggr.go b/app/vmselect/promql/aggr.go index 9baa1efdc..70128935e 100644 --- a/app/vmselect/promql/aggr.go +++ b/app/vmselect/promql/aggr.go @@ -7,6 +7,7 @@ import ( "strconv" "strings" + "github.com/VictoriaMetrics/VictoriaMetrics/lib/bytesutil" "github.com/VictoriaMetrics/VictoriaMetrics/lib/logger" "github.com/VictoriaMetrics/VictoriaMetrics/lib/storage" "github.com/VictoriaMetrics/metrics" @@ -118,13 +119,14 @@ func aggrFuncExt(afe func(tss []*timeseries, modifier *metricsql.ModifierExpr) [ if keepOriginal { ts = argOrig[i] } - tss := m[string(bb.B)] + k := bytesutil.InternBytes(bb.B) + tss := m[k] if tss == nil && maxSeries > 0 && len(m) >= maxSeries { // We already reached time series limit after grouping. Skip other time series. continue } tss = append(tss, ts) - m[string(bb.B)] = tss + m[k] = tss } bbPool.Put(bb)