Use BatchCoaleser in Sort Merge Join, new benchmarks
#18875
Draft
+787
−96
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Rationale for this change
DataFusion Comet often uses Sort Merge Joins because DataFusion does have a larger-than-memory Hash Join operator. Performance on TPC-H Q21 is quite bad when run through native, and instead Comet falls back to Spark by default. If you force Comet to use DataFusion's SMJ operator, performance is:
Profiling showed most of the time spent in
concat_batchesof single-digit rows:What changes are included in this PR?
Use a
BatchCoalescerboth internally and to buffer final output. One made the biggest difference, but I switched to two to be consistent. Here are Comet results with the changes based on 50.3 (which is where Comet is):I ported this PR to DF 51 afterwards, and found #17193 changed the API around batch coalescing. I might need to update this to support
LimitedBatchCoalescerlike #18783Benchmark results are below. For the new
smjbenchmark, Q12 is the most like TPC-H Q21 (left anti join with filter) and then there's TPC-H Q21 (with hash join disabled). I tried to run SF10 TPC-H but it seemed like it was going to take hours on my machine. It ran successfully on this PR.Are these changes tested?
Existing Sort Merge Join unit tests, added a new benchmark.
Are there any user-facing changes?
There should not be.