From cbb83e16477808a51edd18dfd86588ceb7b0e42d Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Fri, 19 Dec 2025 18:54:07 +0000 Subject: [PATCH] PromQL: Add a size-1 pool of FPoint slices This should work better when the PromQL engine is executing instant queries and range queries in rapid succession. Signed-off-by: Bryan Boreham --- promql/engine.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/promql/engine.go b/promql/engine.go index 5a08da121c..9f9c01b405 100644 --- a/promql/engine.go +++ b/promql/engine.go @@ -2480,8 +2480,9 @@ func (ev *evaluator) vectorSelectorSingle(it *storage.MemoizedSeriesIterator, of } var ( - fPointPool zeropool.Pool[[]FPoint] - hPointPool zeropool.Pool[[]HPoint] + fPointPool zeropool.Pool[[]FPoint] + fPoint1Pool zeropool.Pool[[]FPoint] + hPointPool zeropool.Pool[[]HPoint] // matrixSelectorHPool holds reusable histogram slices used by the matrix // selector. The key difference between this pool and the hPointPool is that @@ -2492,7 +2493,11 @@ var ( ) func getFPointSlice(sz int) []FPoint { - if p := fPointPool.Get(); p != nil { + if sz == 1 { + if p := fPoint1Pool.Get(); p != nil { + return p + } + } else if p := fPointPool.Get(); p != nil { return p } @@ -2507,7 +2512,11 @@ func getFPointSlice(sz int) []FPoint { // This function is called with an estimated size which often can be over-estimated. func putFPointSlice(p []FPoint) { if p != nil { - fPointPool.Put(p[:0]) + if cap(p) == 1 { + fPoint1Pool.Put(p[:0]) + } else { + fPointPool.Put(p[:0]) + } } }