From 92826b0b4a414e84410068d47639362f54f4fe87 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Wed, 1 Nov 2023 09:57:55 +0100 Subject: [PATCH] app/vmselect/promql: apply SLO-like optimization to all the `count_*_over_time()` functions This is a follow-up for 41a0fdaf39ea99708cf1c899332910965d62dcfc --- app/vmselect/promql/eval.go | 10 +++++++++- app/vmselect/promql/rollup_result_cache.go | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/vmselect/promql/eval.go b/app/vmselect/promql/eval.go index f0ba9dca1..21afcedbe 100644 --- a/app/vmselect/promql/eval.go +++ b/app/vmselect/promql/eval.go @@ -1149,7 +1149,15 @@ func evalInstantRollup(qt *querytracer.Tracer, ec *EvalConfig, funcName string, }, } return evalExpr(qt, ec, be) - case "count_over_time", "sum_over_time", "increase": + case + "count_eq_over_time", + "count_gt_over_time", + "count_le_over_time", + "count_ne_over_time", + "count_over_time", + "increase", + "increase_pure", + "sum_over_time": if iafc != nil && strings.ToLower(iafc.ae.Name) != "sum" { qt.Printf("do not apply instant rollup optimization for non-sum incremental aggregate %s()", iafc.ae.Name) return evalAt(qt, timestamp, window) diff --git a/app/vmselect/promql/rollup_result_cache.go b/app/vmselect/promql/rollup_result_cache.go index d47490e4a..8a370bef1 100644 --- a/app/vmselect/promql/rollup_result_cache.go +++ b/app/vmselect/promql/rollup_result_cache.go @@ -625,7 +625,8 @@ func mergeTimeseries(qt *querytracer.Tracer, a, b []*timeseries, bStart int64, e } tmp.Values = append(tmp.Values, tsB.Values...) if len(tmp.Values) != len(tmp.Timestamps) { - logger.Panicf("BUG: unexpected values after merging new values; got %d; want %d", len(tmp.Values), len(tmp.Timestamps)) + logger.Panicf("BUG: unexpected values after merging new values; got %d; want %d; len(a.Values)=%d; len(b.Values)=%d", + len(tmp.Values), len(tmp.Timestamps), len(tsA.Values), len(tsB.Values)) } rvs = append(rvs, &tmp) }