Uh oh!
There was an error while loading. Please reload this page.
Feat: Revive to use upstream arrow coalesce - #17105
Conversation
alamb
commented
Aug 11, 2025
🤖 |
alamb
commented
Aug 11, 2025
🤖: Benchmark completed Details |
🤔 the new kernel seems to slow down. I wonder if the overhead of precisely sized output batches is causing the issue |
Good point @alamb , i agree this is the only difference. I can add a test PR to make upstream do not generate precisely sized output batches, but when we ensure capacity for the increment buffer size, it seems we need to make the size change since we do not keep the same target size for this change. The latest benchmark seems a little better.
|
alamb
commented
Aug 11, 2025
Thanks @zhuqi-lucas -- what I was thinking about was something like the following let target_batch_size = 4;letmut coalescer = BatchCoalescer::new(batch1.schema(),4).with_exact_size(false)Before we spend a lot of time polishing / testing a PR for that it would probably be good to hack up a POC and verify it actually improves performance Thank you for your willingness to help along with this project. It is something I have thought was important (but not critical) for a long time and so having someone to help really makes a big difference |
zhuqi-lucas
commented
Aug 11, 2025
Thank you @alamb for good suggestion! It looks pretty cool to me, and a config for this is very clever idea. let target_batch_size = 4;letmut coalescer = BatchCoalescer::new(batch1.schema(),4).with_exact_size(false)I will try to address this for upstream first, so we can easily testing it for datafusion. |
zhuqi-lucas
commented
Aug 12, 2025
2010YOUY01
commented
Aug 13, 2025
For the For certain operators, there might already be an internal mechanism to ensure their output is exactly batch_size. From a quick look at the implementation, the old version could pass such batches through directly, whereas this PR forces them to be copied. Another potential improvement: could we make this pass-through threshold more lenient? For example, if the coalescer receives a batch with size >= |
zhuqi-lucas
commented
Aug 13, 2025
Thank you @2010YOUY01 for review, good suggestion! I will try to address it, and we can get the new benchmark result! |
zhuqi-lucas
commented
Aug 13, 2025
Updated: addressed the comments from @2010YOUY01 , may be we can trigger a new benchmark to see the result @alamb, thanks a lot! |
alamb
commented
Aug 13, 2025
🤖 |
| self.total_rows += batch.num_rows(); | ||
| self.inner.push_batch(batch)?; | ||
| // If the number of rows in the current batch exceeds the coalesce size, |
There was a problem hiding this comment.
if this turns out to work well, maybe it would be a good heuristic to add to the underlying coalescer too in non strict mode 🤔
alamb
commented
Aug 13, 2025
🤖: Benchmark completed Details |
zhuqi-lucas
commented
Aug 14, 2025
cc @alamb@2010YOUY01 It seems still regression after addressing the comments. I need more investigation and try. |
alamb
commented
Aug 14, 2025
Man this one is tricky -- like many performance optimization quests, it will likely take careful engineering and investigation. It is fascinating to me that what in theory should be a net neutral change is turning out to be slower in some cases |
zhuqi-lucas
commented
Aug 14, 2025
Thank you @alamb , i still not give up until now: Submitted another try here: Can i get a benchmark for this PR, thanks a lot! |
alamb
commented
Aug 22, 2025
superceded by #17193 |
Which issue does this PR close?
Revive Draft: Use upstream arrow
coalescekernel in DataFusion #16249Related to Optimize take/filter/concat from multiple input arrays to a single large output array arrow-rs#6692
Related to Enable parquet filter pushdown (
filter_pushdown) by default #3463Rationale for this change
coalescekernel in DataFusion #16249And fix conflicts
filter_pushdown) by default #3463What changes are included in this PR?
This PR refactors the BatchCoalescer in DataFusion to use the proposed upstream API to show that it
Can be used (api is complete enough)
Is not any slower
Are these changes tested?
Yes
Are there any user-facing changes?
No