perf(core): reuse shuffle partition-index buffers across batches - #2359
Merged
Dandandan merged 1 commit intoAug 24, 2026
Merged
Conversation
Dandandan
reviewed
Aug 24, 2026
| rows.clear(); | ||
| } | ||
| for (row, &h) in hash_buffer.iter().enumerate() { | ||
| out[(h % num_partitions as u64) as usize].push(row as u32); |
Contributor
There was a problem hiding this comment.
This is also a slow path (modulo is extremely slow on CPUs), in DataFusion I went so far to replace it with strength reduce apache/datafusion#21900
Contributor
Author
There was a problem hiding this comment.
Interesting, I'll try to incorporate that too!
Contributor
Author
There was a problem hiding this comment.
Actually I'll make a follow up PR today / tomorrow for that change, to make it easier for maintainers to review/approve. Thanks for the suggestion and an implementation to reference :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?
Closes #.
Rationale for this change
compute_partition_indicesallocated a freshVec<Vec<u32>>per input batchnum_partitionsvectors grown from zero, then dropped oncepush_batchcopiedthe indices out. The churn scales with the output partition count.
What changes are included in this PR?
Copying the hash_buffer implementation that already exists in compute_partition_indices,
it now writes into a caller-owned buffer whose inner
Vecs are cleared ratherthan dropped, so capacity survives into the next batch. Partition assignment is
unchanged.
AI Benchmark:
100 batches x 8192 rows, hash on
l_orderkey, release, best of 5 — timinghash + index build +
push_batch:Are there any user-facing changes?
No