Kristofferjoha opened a new pull request, #27994:
URL: https://github.com/apache/datafusion/pull/27994

   ## Which issue does this PR close?
   
   - Part of #27323. This is the repartition over-counting part. The merge 
holding every input batch is still open.
   
   ## Rationale for this change
   
   An order-preserving `RepartitionExec` runs out of memory way before it 
should. The partitioner gives each output partition a slice of one shared 
batch, and each slice is charged for the whole batch (for Utf8View, also for 
every string in the input). With N partitions we charge about N times what we 
actually hold.
   
   For example, a streaming window over a 2M-row file sorted by `k` (with 
`prefer_existing_sort = true`) needs `-m 391M` at 8 partitions and `-m 1765M` 
at 16.
   
   ## What changes are included in this PR?
   
   In order-preserving mode, take each partition's rows separately and compact 
view arrays, so each output batch only holds its own rows. The unordered path 
is unchanged.
   
   ## What is the testing strategy for this PR?
   
   - New `repartition_preserve_order_memory.slt`: the window query on 50k rows 
at a 20M limit. It fails on main, passes here, and runs in about 0.3s.
   - Unit test checking that the 8 outputs of one batch add up to about the 
input size, not 8x.
   
   | Window query | main | This PR |
   |---|---|---|
   | Min memory, 8 / 16 partitions | 391M / 1765M | 53M / 197M |
   | Time, Utf8View, 8 partitions | 77 ms | 100 ms |
   | Time, integers, 8 partitions | 47 ms | 51 ms |
   
   The extra time is copying strings into each partition's own buffer. 
`clickbench_sorted` Q01 hits this path, but I couldn't run it locally.
   
   ## Are there any user-facing changes?
   
   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]

Reply via email to