-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Remove FilterExec from CoalesceBatches optimization rule, add fetch support #18630
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
Remove FilterExec from CoalesceBatches optimization rule, add fetch support #18630
Conversation
|
🤖 |
|
🤖: Benchmark completed Details
|
|
🤖 |
|
🤖: Benchmark completed Details
|
|
Looks like performance (as expected) is roughly the same. |
…row-datafusion into remove_coalesce_batches_exec
alamb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @Dandandan -- these plans are so much nicer to read
I feel there may be some follow ons. I can file some tickets if you agree
- Somehow standardize on LimitedBatchCoalescer
- Support
LimitedBatchCoalescer::push_batch_with_filter - Apply this same pattern to
HashJoinExecandRepartitionExecand then removeCoalesceBatchesentirely 🤔
|
|
||
| self.batch_coalescer.push_batch_with_filter(batch.clone(), filter_array)?; | ||
| Ok(()) | ||
| // TODO: support push_batch_with_filter in LimitedBatchCoalescer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a good todo -- it would be good to file as a follow on ticket / PR perhaps
I can do it if you like
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, that would be nice
| // The goal here is to detect operators that could produce small batches and only | ||
| // wrap those ones with a CoalesceBatchesExec operator. An alternate approach here | ||
| // would be to build the coalescing logic directly into the operators | ||
| // See https://github.com/apache/datafusion/issues/139 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment could probably be removed now (the ticket is long since closed)
| // See https://github.com/apache/datafusion/issues/139 | ||
| let wrap_in_coalesce = plan_any.downcast_ref::<FilterExec>().is_some() | ||
| || plan_any.downcast_ref::<HashJoinExec>().is_some() | ||
| let wrap_in_coalesce = plan_any.downcast_ref::<HashJoinExec>().is_some() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we only have HashJoinExec and RepartitionExec to update before we could remove CoalesceBatches entirely 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes - I tried to apply this optimization to RepartitionExec but unfortunately got some regressions (my feeling is due to some decreased parallelism / work distribution).
HashJoinExec would be a great candidate as it might be possible to avoid the take followed by concat which might speed up things.
|
Thank you for the review @geoffreyclaude and @martin-g |
…upport (apache#18630) 0## 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 `Closes apache#123` indicates that this PR will close issue apache#123. --> - Closes apache#18646 ## Rationale for this change Cleans up the plan by removing `CoalesceBatchesExec`. I do not expect any performance improvement. <!-- 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. --> Making plans better to read and avoid useless `CoalesceBatchesExec` Also adds back fetch support by adding it to FilterExec ## 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. --> ## 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)? --> ## 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. -->

0## Which issue does this PR close?
Rationale for this change
Cleans up the plan by removing
CoalesceBatchesExec. I do not expect any performance improvement.Making plans better to read and avoid useless
CoalesceBatchesExecAlso adds back fetch support by adding it to FilterExec
What changes are included in this PR?
Are these changes tested?
Are there any user-facing changes?