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

   ## Which issue does this PR close?
   
   - Part of #23982 
   
   ## Rationale for this change
   
   After each emission, BoundedWindowAggStream prunes the rows of each 
partition's buffered batch that no longer contribute to any window frame. The 
prune loop re-sliced every live partition's RecordBatch even when there was 
nothing to prune, allocating fresh array metadata for an identical batch and 
then dropping the replaced one.
   
   Profiling the many-partitions benchmark showed prune_state at ~39% of the 
sparse case, where nearly all live partitions are quiet and almost every slice 
is a no-op, and ~21% of the dense case, where most slices prune real rows and 
only the partitions missed by a batch hit the no-op path.
   
   One simple improvement is to leave a partition's buffered batch untouched 
when the prune count is zero. This avoids the array metadata allocation churn 
mentioned above.
   
   Benchmarks:
   
   ```
   - linear, range, single, 100 part, dense:    44.1 ms  -> 43.8 ms (~noise)
   - linear, range, single, 10000 part, dense:  171.1 ms -> 164.8 ms (-3.6%)
   - linear, range, single, 32768 part, sparse: 209.4 ms -> 166.1 ms (-20.6%)
   - linear, rows,  single, 10000 part, dense:  141.5 ms -> 136.4 ms (-3.7%)
   - linear, range, multi,  10000 part, dense:  268.0 ms -> 261.0 ms (-2.6%)
   - sorted, range, single, 10000 part:         34.0 ms  -> 34.3 ms (+0.9%)
   ```
   
   ## What changes are included in this PR?
   
   See above.
   
   ## Are these changes tested?
   
   Covered by existing tests.
   
   ## 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