app/vmselect/promql: apply SLO-like optimization to all the count_*_over_time() functions

This is a follow-up for 41a0fdaf39
This commit is contained in:
Aliaksandr Valialkin 2023-11-01 09:57:55 +01:00
parent 0189081490
commit 92826b0b4a
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1
2 changed files with 11 additions and 2 deletions

View file

@ -1149,7 +1149,15 @@ func evalInstantRollup(qt *querytracer.Tracer, ec *EvalConfig, funcName string,
}, },
} }
return evalExpr(qt, ec, be) 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" { 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) qt.Printf("do not apply instant rollup optimization for non-sum incremental aggregate %s()", iafc.ae.Name)
return evalAt(qt, timestamp, window) return evalAt(qt, timestamp, window)

View file

@ -625,7 +625,8 @@ func mergeTimeseries(qt *querytracer.Tracer, a, b []*timeseries, bStart int64, e
} }
tmp.Values = append(tmp.Values, tsB.Values...) tmp.Values = append(tmp.Values, tsB.Values...)
if len(tmp.Values) != len(tmp.Timestamps) { 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) rvs = append(rvs, &tmp)
} }