From 993618adea442fb8ba19a3c36a3c01c434b3cfc5 Mon Sep 17 00:00:00 2001 From: Charles Korn Date: Wed, 28 Jun 2023 15:13:58 +1000 Subject: [PATCH] Don't create a new iterator for every time step. Signed-off-by: Charles Korn --- promql/engine.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/promql/engine.go b/promql/engine.go index 6fbaba505..ed801a683 100644 --- a/promql/engine.go +++ b/promql/engine.go @@ -1830,6 +1830,7 @@ func (ev *evaluator) evalTimestampFunctionOverVectorSelector(vs *parser.VectorSe if err != nil { ev.error(errWithWarnings{fmt.Errorf("expanding series: %w", err), ws}) } + it := storage.NewMemoizedEmptyIterator(durationMilliseconds(ev.lookbackDelta)) return ev.rangeEval(nil, func(v []parser.Value, _ [][]EvalSeriesHelper, enh *EvalNodeHelper) (Vector, storage.Warnings) { if vs.Timestamp != nil { @@ -1838,7 +1839,6 @@ func (ev *evaluator) evalTimestampFunctionOverVectorSelector(vs *parser.VectorSe vs.Offset = time.Duration(enh.Ts-*vs.Timestamp) * time.Millisecond } vec := make(Vector, 0, len(vs.Series)) - it := storage.NewMemoizedEmptyIterator(durationMilliseconds(ev.lookbackDelta)) var chkIter chunkenc.Iterator for _, s := range vs.Series { chkIter = s.Iterator(chkIter)