Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MQE: add support for sort and sort_desc #10487

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

charleskorn
Copy link
Contributor

What this PR does

This PR adds support in MQE for sort and sort_desc.

Performance compared to Prometheus' engine is slightly better, and peak memory consumption is the same:

goos: darwin
goarch: arm64
pkg: github.com/grafana/mimir/pkg/streamingpromql/benchmarks
cpu: Apple M1 Pro
                                     │ Prometheus  │               Mimir               │
                                     │   sec/op    │   sec/op     vs base              │
Query/sort(a_1),_instant_query-10      146.4µ ± 2%   142.4µ ± 2%  -2.71% (p=0.009 n=6)
Query/sort(a_100),_instant_query-10    839.6µ ± 1%   798.6µ ± 2%  -4.88% (p=0.002 n=6)
Query/sort(a_2000),_instant_query-10   11.14m ± 1%   10.78m ± 1%  -3.18% (p=0.002 n=6)
geomean                                1.110m        1.070m       -3.59%

                                     │  Prometheus  │               Mimir                │
                                     │      B       │      B        vs base              │
Query/sort(a_1),_instant_query-10      66.26Mi ± 1%   65.87Mi ± 1%       ~ (p=0.310 n=6)
Query/sort(a_100),_instant_query-10    61.38Mi ± 1%   60.78Mi ± 1%       ~ (p=0.128 n=6)
Query/sort(a_2000),_instant_query-10   62.58Mi ± 1%   62.93Mi ± 1%       ~ (p=0.143 n=6)
geomean                                63.37Mi        63.16Mi       -0.33%

Given sort and sort_desc only apply to instant queries and we have to load the entire set of data into memory to sort it, there's not much room for improvement over Prometheus' engine.

Which issue(s) this PR fixes or relates to

#10067

Checklist

  • Tests updated.
  • [n/a] Documentation added.
  • [covered by Mimir Query Engine #10067] CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX].
  • [n/a] about-versioning.md updated with experimental features.

This was referenced Jan 21, 2025
@charleskorn charleskorn marked this pull request as ready for review January 21, 2025 04:34
@charleskorn charleskorn requested a review from a team as a code owner January 21, 2025 04:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant