EmilyMatt opened a new pull request, #22945:
URL: https://github.com/apache/datafusion/pull/22945
## 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.
-->
I've encountered several cases where the merge reservation cannot acquire
the minimum reservation needed(2 streams, with a buffer size of 1), we
currently error in these cases but that's not a necessity.
I've implemented a simple re-spill mechanism for when the first 2 streams
cannot be reserved: we take the larger of those streams, and we re-spill it
with all its batches split in half(done using slice() so no copying happens at
that stage and we'll have a smaller memory peak)
This converges until we have enough memory to perform the merge(because
max_record_batch_size is halved, ideally)
I've encountered this in situations where there is heavy skew, so maybe in
the future might be worth it running this in general whenever one stream has a
max_record_batch_size that is far above the other streams, could greatly
improve performance of the entire merge stream at the cost of re-spilling once.
## 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.
-->
Aforementioned implementation
## 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)?
-->
Yes
## 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
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]