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 label_join #10587

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

Conversation

jhesketh
Copy link
Contributor

@jhesketh jhesketh commented Feb 5, 2025

What this PR does

Which issue(s) this PR fixes or relates to

Fixes #

Checklist

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

@jhesketh jhesketh requested a review from a team as a code owner February 5, 2025 12:02
@jhesketh jhesketh mentioned this pull request Feb 5, 2025
Copy link
Contributor

@charleskorn charleskorn left a comment

Choose a reason for hiding this comment

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

Overall LGTM.

Could you please enable the existing label_join benchmark in pkg/streamingpromql/benchmarks/benchmarks.go and post the comparison between MQE and Prometheus' engine?

pkg/streamingpromql/operators/functions/label.go Outdated Show resolved Hide resolved
pkg/streamingpromql/functions.go Show resolved Hide resolved
pkg/streamingpromql/operators/functions/label.go Outdated Show resolved Hide resolved
@jhesketh jhesketh force-pushed the jhesketh/mqe-label_replace branch from 3146152 to 4ec499d Compare February 17, 2025 13:04
Copy link
Contributor

@charleskorn charleskorn left a comment

Choose a reason for hiding this comment

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

LGTM - could you please share the benchmark results?

@jhesketh
Copy link
Contributor Author

Benchmark results


                                                                                    │  Prometheus  │               Mimir                │
                                                                                    │    sec/op    │    sec/op     vs base              │
Query/label_replace(a_1,_'l2',_'$1',_'l',_'(.*)'),_instant_query-8                    754.1µ ±  7%   708.3µ ±  1%  -6.08% (p=0.002 n=6)
Query/label_replace(a_1,_'l2',_'$1',_'l',_'(.*)'),_range_query_with_100_steps-8       784.2µ ± 14%   734.1µ ±  4%  -6.38% (p=0.002 n=6)
Query/label_replace(a_1,_'l2',_'$1',_'l',_'(.*)'),_range_query_with_1000_steps-8      925.5µ ±  2%   866.2µ ±  1%  -6.41% (p=0.002 n=6)
Query/label_replace(a_100,_'l2',_'$1',_'l',_'(.*)'),_instant_query-8                  2.459m ±  1%   2.436m ±  5%       ~ (p=0.589 n=6)
Query/label_replace(a_100,_'l2',_'$1',_'l',_'(.*)'),_range_query_with_100_steps-8     3.608m ±  1%   3.571m ±  1%  -1.01% (p=0.026 n=6)
Query/label_replace(a_100,_'l2',_'$1',_'l',_'(.*)'),_range_query_with_1000_steps-8    14.29m ±  5%   14.17m ± 10%       ~ (p=0.589 n=6)
Query/label_replace(a_2000,_'l2',_'$1',_'l',_'(.*)'),_instant_query-8                 28.92m ±  2%   27.48m ±  2%  -4.98% (p=0.002 n=6)
Query/label_replace(a_2000,_'l2',_'$1',_'l',_'(.*)'),_range_query_with_100_steps-8    52.52m ±  1%   51.59m ±  3%       ~ (p=0.310 n=6)
Query/label_replace(a_2000,_'l2',_'$1',_'l',_'(.*)'),_range_query_with_1000_steps-8   251.5m ±  0%   245.0m ±  2%  -2.61% (p=0.004 n=6)
Query/label_join(a_1,_'l2',_'-',_'l',_'l'),_instant_query-8                           760.4µ ±  4%   700.6µ ±  2%  -7.86% (p=0.002 n=6)
Query/label_join(a_1,_'l2',_'-',_'l',_'l'),_range_query_with_100_steps-8              742.5µ ±  5%   711.1µ ±  2%  -4.23% (p=0.002 n=6)
Query/label_join(a_1,_'l2',_'-',_'l',_'l'),_range_query_with_1000_steps-8             888.1µ ±  1%   841.4µ ±  2%  -5.26% (p=0.002 n=6)
Query/label_join(a_100,_'l2',_'-',_'l',_'l'),_instant_query-8                         2.397m ±  1%   2.353m ±  1%  -1.82% (p=0.009 n=6)
Query/label_join(a_100,_'l2',_'-',_'l',_'l'),_range_query_with_100_steps-8            3.604m ±  1%   3.506m ± 11%       ~ (p=0.065 n=6)
Query/label_join(a_100,_'l2',_'-',_'l',_'l'),_range_query_with_1000_steps-8           14.19m ±  3%   14.37m ±  4%       ~ (p=0.240 n=6)
Query/label_join(a_2000,_'l2',_'-',_'l',_'l'),_instant_query-8                        27.75m ±  3%   26.92m ±  2%  -3.00% (p=0.002 n=6)
Query/label_join(a_2000,_'l2',_'-',_'l',_'l'),_range_query_with_100_steps-8           52.13m ±  2%   50.50m ±  2%  -3.12% (p=0.002 n=6)
Query/label_join(a_2000,_'l2',_'-',_'l',_'l'),_range_query_with_1000_steps-8          249.4m ±  2%   246.3m ±  0%  -1.23% (p=0.002 n=6)
geomean                                                                               6.615m         6.396m        -3.31%

                                                                                    │  Prometheus  │                Mimir                │
                                                                                    │     B/op     │     B/op      vs base               │
Query/label_replace(a_1,_'l2',_'$1',_'l',_'(.*)'),_instant_query-8                    27.72Ki ± 0%   24.70Ki ± 0%  -10.91% (p=0.002 n=6)
Query/label_replace(a_1,_'l2',_'$1',_'l',_'(.*)'),_range_query_with_100_steps-8       28.82Ki ± 0%   25.43Ki ± 0%  -11.77% (p=0.002 n=6)
Query/label_replace(a_1,_'l2',_'$1',_'l',_'(.*)'),_range_query_with_1000_steps-8      33.36Ki ± 0%   29.95Ki ± 0%  -10.20% (p=0.002 n=6)
Query/label_replace(a_100,_'l2',_'$1',_'l',_'(.*)'),_instant_query-8                  184.3Ki ± 0%   163.4Ki ± 0%  -11.33% (p=0.002 n=6)
Query/label_replace(a_100,_'l2',_'$1',_'l',_'(.*)'),_range_query_with_100_steps-8     235.7Ki ± 0%   221.0Ki ± 0%   -6.20% (p=0.002 n=6)
Query/label_replace(a_100,_'l2',_'$1',_'l',_'(.*)'),_range_query_with_1000_steps-8    659.4Ki ± 1%   644.1Ki ± 0%   -2.31% (p=0.002 n=6)
Query/label_replace(a_2000,_'l2',_'$1',_'l',_'(.*)'),_instant_query-8                 3.165Mi ± 0%   2.825Mi ± 1%  -10.76% (p=0.002 n=6)
Query/label_replace(a_2000,_'l2',_'$1',_'l',_'(.*)'),_range_query_with_100_steps-8    4.165Mi ± 0%   4.016Mi ± 1%   -3.58% (p=0.002 n=6)
Query/label_replace(a_2000,_'l2',_'$1',_'l',_'(.*)'),_range_query_with_1000_steps-8   12.41Mi ± 2%   12.05Mi ± 0%   -2.89% (p=0.002 n=6)
Query/label_join(a_1,_'l2',_'-',_'l',_'l'),_instant_query-8                           24.93Ki ± 0%   21.88Ki ± 0%  -12.23% (p=0.002 n=6)
Query/label_join(a_1,_'l2',_'-',_'l',_'l'),_range_query_with_100_steps-8              25.99Ki ± 0%   22.63Ki ± 0%  -12.92% (p=0.002 n=6)
Query/label_join(a_1,_'l2',_'-',_'l',_'l'),_range_query_with_1000_steps-8             30.52Ki ± 0%   27.07Ki ± 0%  -11.33% (p=0.002 n=6)
Query/label_join(a_100,_'l2',_'-',_'l',_'l'),_instant_query-8                         175.9Ki ± 0%   156.8Ki ± 0%  -10.87% (p=0.002 n=6)
Query/label_join(a_100,_'l2',_'-',_'l',_'l'),_range_query_with_100_steps-8            227.1Ki ± 0%   214.3Ki ± 0%   -5.63% (p=0.002 n=6)
Query/label_join(a_100,_'l2',_'-',_'l',_'l'),_range_query_with_1000_steps-8           649.9Ki ± 1%   637.8Ki ± 1%   -1.87% (p=0.002 n=6)
Query/label_join(a_2000,_'l2',_'-',_'l',_'l'),_instant_query-8                        3.073Mi ± 0%   2.792Mi ± 0%   -9.17% (p=0.002 n=6)
Query/label_join(a_2000,_'l2',_'-',_'l',_'l'),_range_query_with_100_steps-8           4.074Mi ± 0%   3.983Mi ± 0%   -2.24% (p=0.002 n=6)
Query/label_join(a_2000,_'l2',_'-',_'l',_'l'),_range_query_with_1000_steps-8          12.12Mi ± 2%   12.02Mi ± 0%   -0.86% (p=0.002 n=6)
geomean                                                                               361.7Ki        333.8Ki        -7.71%

                                                                                    │ Prometheus  │               Mimir                │
                                                                                    │  allocs/op  │  allocs/op   vs base               │
Query/label_replace(a_1,_'l2',_'$1',_'l',_'(.*)'),_instant_query-8                     514.0 ± 0%    422.0 ± 0%  -17.90% (p=0.002 n=6)
Query/label_replace(a_1,_'l2',_'$1',_'l',_'(.*)'),_range_query_with_100_steps-8        524.0 ± 0%    429.0 ± 0%  -18.13% (p=0.002 n=6)
Query/label_replace(a_1,_'l2',_'$1',_'l',_'(.*)'),_range_query_with_1000_steps-8       550.0 ± 0%    455.0 ± 0%  -17.27% (p=0.002 n=6)
Query/label_replace(a_100,_'l2',_'$1',_'l',_'(.*)'),_instant_query-8                  2.824k ± 0%   2.724k ± 0%   -3.54% (p=0.002 n=6)
Query/label_replace(a_100,_'l2',_'$1',_'l',_'(.*)'),_range_query_with_100_steps-8     3.236k ± 0%   3.135k ± 0%   -3.14% (p=0.002 n=6)
Query/label_replace(a_100,_'l2',_'$1',_'l',_'(.*)'),_range_query_with_1000_steps-8    5.852k ± 0%   5.750k ± 0%   -1.73% (p=0.002 n=6)
Query/label_replace(a_2000,_'l2',_'$1',_'l',_'(.*)'),_instant_query-8                 47.03k ± 0%   46.90k ± 0%   -0.27% (p=0.002 n=6)
Query/label_replace(a_2000,_'l2',_'$1',_'l',_'(.*)'),_range_query_with_100_steps-8    55.07k ± 0%   54.97k ± 0%   -0.19% (p=0.002 n=6)
Query/label_replace(a_2000,_'l2',_'$1',_'l',_'(.*)'),_range_query_with_1000_steps-8   107.2k ± 0%   107.0k ± 0%   -0.12% (p=0.002 n=6)
Query/label_join(a_1,_'l2',_'-',_'l',_'l'),_instant_query-8                            473.0 ± 0%    381.0 ± 0%  -19.45% (p=0.002 n=6)
Query/label_join(a_1,_'l2',_'-',_'l',_'l'),_range_query_with_100_steps-8               483.0 ± 0%    388.0 ± 0%  -19.67% (p=0.002 n=6)
Query/label_join(a_1,_'l2',_'-',_'l',_'l'),_range_query_with_1000_steps-8              509.0 ± 0%    414.0 ± 0%  -18.66% (p=0.002 n=6)
Query/label_join(a_100,_'l2',_'-',_'l',_'l'),_instant_query-8                         2.585k ± 0%   2.493k ± 0%   -3.56% (p=0.002 n=6)
Query/label_join(a_100,_'l2',_'-',_'l',_'l'),_range_query_with_100_steps-8            2.997k ± 0%   2.903k ± 0%   -3.14% (p=0.002 n=6)
Query/label_join(a_100,_'l2',_'-',_'l',_'l'),_range_query_with_1000_steps-8           5.613k ± 0%   5.519k ± 0%   -1.67% (p=0.002 n=6)
Query/label_join(a_2000,_'l2',_'-',_'l',_'l'),_instant_query-8                        42.99k ± 0%   43.87k ± 0%   +2.04% (p=0.002 n=6)
Query/label_join(a_2000,_'l2',_'-',_'l',_'l'),_range_query_with_100_steps-8           51.02k ± 0%   51.93k ± 0%   +1.77% (p=0.002 n=6)
Query/label_join(a_2000,_'l2',_'-',_'l',_'l'),_range_query_with_1000_steps-8          103.1k ± 0%   104.0k ± 0%   +0.89% (p=0.002 n=6)
geomean                                                                               4.886k        4.530k        -7.27%

                                                                                    │  Prometheus  │               Mimir                │
                                                                                    │      B       │      B        vs base              │
Query/label_replace(a_1,_'l2',_'$1',_'l',_'(.*)'),_instant_query-8                    68.58Mi ± 2%   68.63Mi ± 1%       ~ (p=0.937 n=6)
Query/label_replace(a_1,_'l2',_'$1',_'l',_'(.*)'),_range_query_with_100_steps-8       68.52Mi ± 2%   67.93Mi ± 1%       ~ (p=0.589 n=6)
Query/label_replace(a_1,_'l2',_'$1',_'l',_'(.*)'),_range_query_with_1000_steps-8      68.10Mi ± 1%   67.60Mi ± 1%  -0.73% (p=0.022 n=6)
Query/label_replace(a_100,_'l2',_'$1',_'l',_'(.*)'),_instant_query-8                  65.83Mi ± 1%   65.45Mi ± 2%       ~ (p=0.240 n=6)
Query/label_replace(a_100,_'l2',_'$1',_'l',_'(.*)'),_range_query_with_100_steps-8     66.33Mi ± 1%   66.26Mi ± 1%       ~ (p=0.699 n=6)
Query/label_replace(a_100,_'l2',_'$1',_'l',_'(.*)'),_range_query_with_1000_steps-8    69.04Mi ± 1%   69.14Mi ± 1%       ~ (p=0.485 n=6)
Query/label_replace(a_2000,_'l2',_'$1',_'l',_'(.*)'),_instant_query-8                 67.40Mi ± 1%   67.23Mi ± 1%       ~ (p=0.937 n=6)
Query/label_replace(a_2000,_'l2',_'$1',_'l',_'(.*)'),_range_query_with_100_steps-8    73.86Mi ± 1%   76.00Mi ± 1%  +2.91% (p=0.002 n=6)
Query/label_replace(a_2000,_'l2',_'$1',_'l',_'(.*)'),_range_query_with_1000_steps-8   126.0Mi ± 3%   130.2Mi ± 1%  +3.34% (p=0.002 n=6)
Query/label_join(a_1,_'l2',_'-',_'l',_'l'),_instant_query-8                           68.84Mi ± 1%   68.88Mi ± 2%       ~ (p=0.699 n=6)
Query/label_join(a_1,_'l2',_'-',_'l',_'l'),_range_query_with_100_steps-8              69.64Mi ± 2%   68.68Mi ± 1%       ~ (p=0.065 n=6)
Query/label_join(a_1,_'l2',_'-',_'l',_'l'),_range_query_with_1000_steps-8             68.47Mi ± 2%   68.22Mi ± 2%       ~ (p=0.589 n=6)
Query/label_join(a_100,_'l2',_'-',_'l',_'l'),_instant_query-8                         65.70Mi ± 1%   65.72Mi ± 1%       ~ (p=0.818 n=6)
Query/label_join(a_100,_'l2',_'-',_'l',_'l'),_range_query_with_100_steps-8            65.99Mi ± 1%   66.22Mi ± 1%       ~ (p=0.589 n=6)
Query/label_join(a_100,_'l2',_'-',_'l',_'l'),_range_query_with_1000_steps-8           68.96Mi ± 1%   68.94Mi ± 1%       ~ (p=0.589 n=6)
Query/label_join(a_2000,_'l2',_'-',_'l',_'l'),_instant_query-8                        67.35Mi ± 3%   67.76Mi ± 1%       ~ (p=0.132 n=6)
Query/label_join(a_2000,_'l2',_'-',_'l',_'l'),_range_query_with_100_steps-8           74.35Mi ± 1%   76.10Mi ± 2%  +2.35% (p=0.002 n=6)
Query/label_join(a_2000,_'l2',_'-',_'l',_'l'),_range_query_with_1000_steps-8          129.3Mi ± 2%   129.6Mi ± 1%       ~ (p=0.394 n=6)
geomean                                                                               73.42Mi        73.65Mi       +0.31%


tldr: >10% better memory, 3-5% better CPU

@charleskorn
Copy link
Contributor

I'm surprised to see that MQE allocates more often than Prometheus' engine for label_join over many series - any idea why that is? (I'm wondering if we've missed something.)

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