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

Mimir query engine: improve performance for case where right side of binary operation has fewer series than the left side #8276

Merged
merged 4 commits into from
Jun 6, 2024

Conversation

charleskorn
Copy link
Contributor

@charleskorn charleskorn commented Jun 5, 2024

What this PR does

This PR improves the performance of binary operations for queries where the right side has fewer series than the left side.

Benchmark results for a query where the left side (a_2000) has 2000 series, and the right side has one series:

                                                                                    │ original.txt  │             after.txt              │
                                                                                    │    sec/op     │   sec/op     vs base               │
Query/a_2000_-_b_2000{l="1234"},_instant_query/streaming-10                            6.917m ±  4%   6.327m ± 1%   -8.53% (p=0.002 n=6)
Query/a_2000_-_b_2000{l="1234"},_range_query_with_100_steps/streaming-10              10.391m ±  6%   9.670m ± 1%   -6.94% (p=0.002 n=6)
Query/a_2000_-_b_2000{l="1234"},_range_query_with_1000_steps/streaming-10              47.98m ±  4%   46.55m ± 1%   -2.98% (p=0.041 n=6)

Latency and peak memory utilisation is unchanged for other benchmarks, and peak memory utilisation is only marginally affected for the benchmark above.

Which issue(s) this PR fixes or relates to

Resolves a TODO from #8096

Checklist

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

@charleskorn charleskorn marked this pull request as ready for review June 5, 2024 05:55
@charleskorn charleskorn requested a review from a team as a code owner June 5, 2024 05:55
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.

Nice, lgtm!

@charleskorn charleskorn enabled auto-merge (squash) June 6, 2024 02:42
@charleskorn charleskorn merged commit c8c06f2 into main Jun 6, 2024
29 checks passed
@charleskorn charleskorn deleted the charleskorn/uneven-binary-op branch June 6, 2024 03:06
narqo pushed a commit to narqo/grafana-mimir that referenced this pull request Jun 6, 2024
…binary operation has fewer series than the left side (grafana#8276)

* Change binary operators test to use subtraction to catch any issues where sides are inverted

* Improve performance for case where right side of binary operator has fewer series than the left side.

* Add changelog entry
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.

2 participants