thanos-io / promql-engine

Multi-threaded PromQL engine implementation based on the Volcano paper.
Apache License 2.0
133 stars 52 forks source link

Add suport for range subqueries #375

Closed fpetkovski closed 6 months ago

fpetkovski commented 6 months ago

This commit extends the implementation of subqueries to also cover range queries. It does that by introducing a generic, timestamp-aware ringbuffer which can be used to add and drop samples within a certain window.

For now the ringbuffer is only used for subqueries, but the idea is to also use it in the matrix selector to simplify the windowing logic.

fpetkovski commented 6 months ago

Posting benchmark results for reference

CPU
RangeQuery/subquery-8       81.9ms ± 0%    37.7ms ± 1%   -53.91%  (p=0.008 n=5+5)

Mem
RangeQuery/subquery-8       24.2MB ± 0%    31.5MB ± 0%   +30.49%  (p=0.008 n=5+5)`