-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Minor] Reuse indices buffer in RepartitionExec #19775
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
base: main
Are you sure you want to change the base?
[Minor] Reuse indices buffer in RepartitionExec #19775
Conversation
This commit optimizes the `RepartitionExec` operator by reusing the `Vec` allocations for indices in the `BatchPartitioner`. Instead of reallocating the `indices` vector for every `RecordBatch` it processes in hash partitioning mode, this change modifies the `BatchPartitioner` to reuse these allocations across batches. This is achieved by: - Storing the `indices` vectors in the `BatchPartitionerState`. - Clearing the vectors for each new batch. - Using `std::mem::take` to move the data out for processing. - Reclaiming the underlying `Vec` from the Arrow array using `into_parts` after processing, clearing it, and placing it back into the state for the next iteration. This avoids repeated allocations and improves performance, especially when dealing with many small batches.
|
Run benchmarks |
|
🤖 |
|
🤖: Benchmark completed Details
|
|
Run benchmarks |
|
run benchmark tpch tpcds |
1 similar comment
|
run benchmark tpch tpcds |
|
run benchmark tpch tpcds |
This commit optimizes the
RepartitionExecoperator by reusing theVecallocations for indices in theBatchPartitioner. Instead of reallocating theindicesvector for everyRecordBatchit processes in hash partitioning mode, this change modifies theBatchPartitionerto reuse these allocations across batches.This is achieved by:
indicesvectors in theBatchPartitionerState.std::mem::taketo move the data out for processing.Vecfrom the Arrow array usinginto_partsafter processing, clearing it, and placing it back into the state for the next iteration.This avoids repeated allocations and improves performance, especially when dealing with many small batches.
Which issue does this PR close?
Rationale for this change
What changes are included in this PR?
Are these changes tested?
Are there any user-facing changes?