Skip to content

test: scale remaining sort-merge join (SMJ) benchmark queries - #21200

Merged
mbutrovich merged 2 commits into
apache:mainfrom
mbutrovich:smj-bench
Mar 27, 2026
Merged

test: scale remaining sort-merge join (SMJ) benchmark queries#21200
mbutrovich merged 2 commits into
apache:mainfrom
mbutrovich:smj-bench

Conversation

@mbutrovich

@mbutrovichmbutrovich commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

  • Closes #.

Rationale for this change

Our SMJ benchmark queries finish too quickly to demonstrate improvements that aren't massive. For example, I am working on an optimization that introduces DynComparator (part of #20910) and it's about a 10% improvement, but only when you actually make the queries run long enough. The new queries for #21184 are scaled enough to see improvements, but we need to scale the older queries.

I am also continuing to see SMJ issues with Comet when running joins with billions (sometimes trillions) of rows. We can't do that for microbenchmarks, but we can at least start hitting millions of rows to look at more than a handful of batches.

What changes are included in this PR?

Bring our SMJ queries into alignment with some of the newer ones (Q21-23) to demonstrate further performance wins.

Are these changes tested?

I ran the benchmark. On my M3 Max, here's how long it takes:

QueryJoin TypeRowsKeysFilterMedian (ms)
Q1INNER1M×1M1:116.3
Q2INNER1M×10M1:10117.4
Q3INNER1M×1M1:10074.2
Q4INNER1M×10M1:101%17.1
Q5INNER1M×1M1:10010%18.4
Q6LEFT1M×10M1:10129.3
Q7LEFT1M×10M1:1050%150.2
Q8FULL1M×1M1:1016.6
Q9FULL1M×10M1:1010%153.5
Q10LEFT SEMI1M×10M1:1053.1
Q11LEFT SEMI1M×10M1:101%15.5
Q12LEFT SEMI1M×10M1:1050%65.0
Q13LEFT SEMI1M×10M1:1090%105.7
Q14LEFT ANTI1M×10M1:1054.3
Q15LEFT ANTI1M×10M1:10partial51.5
Q16LEFT ANTI1M×1M1:110.3
Q17INNER1M×50M1:505%75.9
Q18LEFT SEMI1M×50M1:502%50.2
Q19LEFT ANTI1M×50M1:50partial336.4
Q20INNER1M×10M1:100GROUP BY763.7
Q21INNER10M×10M1:150%186.1
Q22LEFT10M×10M1:150%10,193.8
Q23FULL10M×10M1:150%10,194.7

Note that Q22 and Q23 will be about 20x faster when #21184 merges, so taking 10 seconds to run is just a short-term issue.

Are there any user-facing changes?

No.

@andygroveandygrove left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Thanks @mbutrovich

@mbutrovich
mbutrovich added this pull request to the merge queueMar 27, 2026
Merged via the queue into apache:main with commit 37c1b75Mar 27, 2026
31 checks passed
@mbutrovich
mbutrovich deleted the smj-bench branch March 27, 2026 15:36
Rich-T-kid pushed a commit to Rich-T-kid/datafusion that referenced this pull request Apr 21, 2026
…#21200)
## Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases.
You can link an issue to this PR using the GitHub syntax. For example
`Closesapache#123` indicates that this PR will close issue apache#123.
-->
- Closes #.
## Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly
in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand
your changes and offer better suggestions for fixes.
-->
Our SMJ benchmark queries finish too quickly to demonstrate improvements
that aren't massive. For example, I am working on an optimization that
introduces `DynComparator` (part of apache#20910) and it's about a 10%
improvement, but only when you actually make the queries run long
enough. The new queries for apache#21184 are scaled enough to see
improvements, but we need to scale the older queries.
I am also continuing to see SMJ issues with Comet when running joins
with billions (sometimes trillions) of rows. We can't do that for
microbenchmarks, but we can at least start hitting millions of rows to
look at more than a handful of batches.
## What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it
is sometimes worth providing a summary of the individual changes in this
PR.
-->
Bring our SMJ queries into alignment with some of the newer ones
(Q21-23) to demonstrate further performance wins.
## Are these changes tested?
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example,
are they covered by existing tests)?
-->
I ran the benchmark. On my M3 Max, here's how long it takes:
| Query | Join Type | Rows | Keys | Filter | Median (ms) |
|-------|-----------|------|------|--------|-------------|
| Q1 | INNER | 1M×1M | 1:1 | — | 16.3 |
| Q2 | INNER | 1M×10M | 1:10 | — | 117.4 |
| Q3 | INNER | 1M×1M | 1:100 | — | 74.2 |
| Q4 | INNER | 1M×10M | 1:10 | 1% | 17.1 |
| Q5 | INNER | 1M×1M | 1:100 | 10% | 18.4 |
| Q6 | LEFT | 1M×10M | 1:10 | — | 129.3 |
| Q7 | LEFT | 1M×10M | 1:10 | 50% | 150.2 |
| Q8 | FULL | 1M×1M | 1:10 | — | 16.6 |
| Q9 | FULL | 1M×10M | 1:10 | 10% | 153.5 |
| Q10 | LEFT SEMI | 1M×10M | 1:10 | — | 53.1 |
| Q11 | LEFT SEMI | 1M×10M | 1:10 | 1% | 15.5 |
| Q12 | LEFT SEMI | 1M×10M | 1:10 | 50% | 65.0 |
| Q13 | LEFT SEMI | 1M×10M | 1:10 | 90% | 105.7 |
| Q14 | LEFT ANTI | 1M×10M | 1:10 | — | 54.3 |
| Q15 | LEFT ANTI | 1M×10M | 1:10 | partial | 51.5 |
| Q16 | LEFT ANTI | 1M×1M | 1:1 | — | 10.3 |
| Q17 | INNER | 1M×50M | 1:50 | 5% | 75.9 |
| Q18 | LEFT SEMI | 1M×50M | 1:50 | 2% | 50.2 |
| Q19 | LEFT ANTI | 1M×50M | 1:50 | partial | 336.4 |
| Q20 | INNER | 1M×10M | 1:100 | GROUP BY | 763.7 |
| Q21 | INNER | 10M×10M | 1:1 | 50% | 186.1 |
| Q22 | LEFT | 10M×10M | 1:1 | 50% | 10,193.8 |
| Q23 | FULL | 10M×10M | 1:1 | 50% | 10,194.7 |
Note that Q22 and Q23 will be about 20x faster when apache#21184 merges, so
taking 10 seconds to run is just a short-term issue.
## Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
-->
<!--
If there are any breaking changes to public APIs, please add the `api
change` label.
-->
No.
Sign up for freeto 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

@mbutrovich@andygrove