From 85150f9dec6329a0566bea2fa1f71c963452bde3 Mon Sep 17 00:00:00 2001 From: Linas Medziunas Date: Thu, 13 Nov 2025 11:37:53 +0200 Subject: [PATCH] [PERF] PromQL: only reset labels builder when needed Signed-off-by: Linas Medziunas --- promql/engine.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/promql/engine.go b/promql/engine.go index 44cef1c1c6..74864bdcae 100644 --- a/promql/engine.go +++ b/promql/engine.go @@ -2951,7 +2951,6 @@ func resultMetric(lhs, rhs labels.Labels, op parser.ItemType, matching *parser.V enh.resultMetric = make(map[string]labels.Labels, len(enh.Out)) } - enh.resetBuilder(lhs) buf := bytes.NewBuffer(enh.lblResultBuf[:0]) enh.lblBuf = lhs.Bytes(enh.lblBuf) buf.Write(enh.lblBuf) @@ -2964,6 +2963,7 @@ func resultMetric(lhs, rhs labels.Labels, op parser.ItemType, matching *parser.V } str := string(enh.lblResultBuf) + enh.resetBuilder(lhs) if changesMetricSchema(op) { // Setting empty Metadata causes the deletion of those if they exists. schema.Metadata{}.SetToLabels(enh.lb)