From c5e3b1176279f7f221b9deda0d2b5047e52eaa40 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 b6b5651e9e..0cf7bf8c34 100644 --- a/app/vmselect/promql/eval.go +++ b/app/vmselect/promql/eval.go @@ -1171,7 +1171,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 765e02d4f9..20986aa6c9 100644 --- a/app/vmselect/promql/rollup_result_cache.go +++ b/app/vmselect/promql/rollup_result_cache.go @@ -583,7 +583,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) }