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 group_left and group_right (aka many-to-one and one-to-many matching) #10119

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

Conversation

charleskorn
Copy link
Contributor

What this PR does

This PR adds support for group_left and group_right (aka many-to-one and one-to-many matching) in binary operations to MQE.

In our benchmarks, latency is up to 80% lower and peak memory utilisation is up to 30% lower with MQE compared to Prometheus' engine:

                                                                         │  Prometheus  │               Mimir                │
                                                                         │    sec/op    │   sec/op     vs base               │
Query/h_1_*_on(l)_group_left()_a_1,_instant_query-10                        321.8µ ± 2%   340.3µ ± 9%        ~ (p=0.065 n=6)
Query/h_1_*_on(l)_group_left()_a_1,_range_query_with_100_steps-10           452.3µ ± 1%   358.5µ ± 2%  -20.74% (p=0.002 n=6)
Query/h_1_*_on(l)_group_left()_a_1,_range_query_with_1000_steps-10         1651.5µ ± 0%   756.0µ ± 3%  -54.23% (p=0.002 n=6)
Query/h_100_*_on(l)_group_left()_a_100,_instant_query-10                    4.694m ± 1%   4.659m ± 2%        ~ (p=0.310 n=6)
Query/h_100_*_on(l)_group_left()_a_100,_range_query_with_100_steps-10      22.581m ± 1%   8.320m ± 1%  -63.16% (p=0.002 n=6)
Query/h_100_*_on(l)_group_left()_a_100,_range_query_with_1000_steps-10     185.37m ± 3%   39.77m ± 0%  -78.55% (p=0.002 n=6)
Query/h_2000_*_on(l)_group_left()_a_2000,_instant_query-10                  84.71m ± 1%   85.24m ± 2%        ~ (p=0.132 n=6)
Query/h_2000_*_on(l)_group_left()_a_2000,_range_query_with_100_steps-10     468.3m ± 1%   155.0m ± 4%  -66.90% (p=0.002 n=6)
Query/h_2000_*_on(l)_group_left()_a_2000,_range_query_with_1000_steps-10   4006.0m ± 2%   761.7m ± 1%  -80.99% (p=0.002 n=6)
geomean                                                                     20.87m        10.41m       -50.14%

                                                                         │   Prometheus   │                Mimir                │
                                                                         │       B        │      B        vs base               │
Query/h_1_*_on(l)_group_left()_a_1,_instant_query-10                        73.48Mi ±  1%   73.76Mi ± 1%        ~ (p=0.699 n=6)
Query/h_1_*_on(l)_group_left()_a_1,_range_query_with_100_steps-10           72.05Mi ±  1%   73.21Mi ± 1%   +1.62% (p=0.002 n=6)
Query/h_1_*_on(l)_group_left()_a_1,_range_query_with_1000_steps-10          70.13Mi ±  1%   70.78Mi ± 1%        ~ (p=0.087 n=6)
Query/h_100_*_on(l)_group_left()_a_100,_instant_query-10                    69.96Mi ±  1%   70.16Mi ± 1%   +0.29% (p=0.015 n=6)
Query/h_100_*_on(l)_group_left()_a_100,_range_query_with_100_steps-10       73.55Mi ±  1%   73.12Mi ± 1%        ~ (p=0.262 n=6)
Query/h_100_*_on(l)_group_left()_a_100,_range_query_with_1000_steps-10     107.05Mi ±  5%   90.28Mi ± 3%  -15.66% (p=0.002 n=6)
Query/h_2000_*_on(l)_group_left()_a_2000,_instant_query-10                  79.68Mi ±  3%   79.24Mi ± 4%        ~ (p=0.485 n=6)
Query/h_2000_*_on(l)_group_left()_a_2000,_range_query_with_100_steps-10     172.9Mi ±  6%   131.9Mi ± 2%  -23.73% (p=0.002 n=6)
Query/h_2000_*_on(l)_group_left()_a_2000,_range_query_with_1000_steps-10    651.3Mi ± 13%   438.1Mi ± 0%  -32.74% (p=0.002 n=6)
geomean                                                                     107.0Mi         97.69Mi        -8.68%

I am not adding a changelog entry given it is covered by the generic MQE changelog entry that links to #10067.

Which issue(s) this PR fixes or relates to

#10067

Checklist

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

"github.com/grafana/mimir/pkg/streamingpromql/types"
)

var errMultipleMatchesOnManySide = errors.New("multiple matches for labels: grouping labels must ensure unique matches")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to reviewers: this error message isn't the best, but it's what Prometheus uses, and including more specific details is difficult.

@charleskorn charleskorn force-pushed the charleskorn/mqe-group-left-right branch from 4f7e673 to 74afbb3 Compare December 4, 2024 03:45
@charleskorn charleskorn marked this pull request as ready for review December 4, 2024 04:08
@charleskorn charleskorn requested review from tacole02 and a team as code owners December 4, 2024 04:08
Copy link
Contributor

@jhesketh jhesketh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me. I admit for some of the review I'm trusting the general approach, unit tests, and benchmarks, but it overall seems good sans a few comments.

@jhesketh
Copy link
Contributor

jhesketh commented Dec 5, 2024

Forgot to add that I think we should see group left/right in the mixed metrics test gauntlet

@charleskorn
Copy link
Contributor Author

Forgot to add that I think we should see group left/right in the mixed metrics test gauntlet

Added in 7214a8e.

@charleskorn charleskorn force-pushed the charleskorn/mqe-group-left-right branch from b72c6f1 to b58c518 Compare December 10, 2024 09:52
@charleskorn charleskorn force-pushed the charleskorn/mqe-group-left-right branch from b58c518 to d2e2a1c Compare December 10, 2024 09:56
@charleskorn charleskorn requested a review from jhesketh December 10, 2024 10:59
Copy link
Contributor

@jhesketh jhesketh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks for addressing the comments!

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.

3 participants