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

   ## 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 #123` 
indicates that this PR will close issue #123.
   -->
   
   - Followup 
https://github.com/apache/datafusion/pull/23192#discussion_r3476455650
   
   ## Rationale for this change
   
     `arrow::buffer::OffsetBufferBuilder` is a thin wrapper around `Vec<O>` 
plus a `last_offset: usize` running counter; every `push_length(n)` does a 
`checked_add` on `usize` and a `usize_as(O)` conversion. For
     per-row loops with a known upfront row count, a direct `Vec<O>` that 
stores the running offset via `offsets[row] + O::usize_as(len)` can save 
measurable work in tight per-row loops — provided the offset push
     is a meaningful fraction of per-row cost.
     
     I swapped the pattern in all eight `OffsetBufferBuilder` call sites in the 
repo (`array_normalize`, `array_filter`, `remove`, `replace`, `array_add`, 
`utils::general_array_zip_with`, `array_scale`,
     `encoding::delegated_decode`), benchmarked the three sites that have 
criterion benches, and found the win is **not** uniform.
   
     ## What changes are included in this PR?
   
     Replace `OffsetBufferBuilder<O>` with `Vec<O>` (preinitialized with 
`O::zero()` and finalized with `OffsetBuffer::new(v.into())`) **only** in 
`datafusion/functions-nested/src/remove.rs`, where benches show
     clean wins with no regressions.
   
     The other seven sites are left on `OffsetBufferBuilder` — benches showed 
flat-to-regressing results, see below.
   
     ## Are these changes tested?
     
     Existing unit tests, doctests, and sqllogictests (`array_remove*`) pass 
unchanged. No new tests — refactor is functionally equivalent.
   
     ## Are there any user-facing changes?
     
     No.
   
     ## Benchmark results
   
   The biggest win is `array_remove`
     
     ### `array_remove`
   
     | Bench | size 10 | size 100 | size 500 |
     |---|---:|---:|---:|
     | `int64` | −0.2% | −1.0% | **−50.0%** |
     | `n_int64` | −0.7% | +0.05% | **−23.1%** |
     | `all_int64` | +0.2% | −1.8% | **−15.1%** |
     | `strings` | +3.8% | +0.6% | **−4.6%** |
     | `boolean` | −0.01% | +1.1% | +0.3% |
     | `fixed_size_binary` | −0.06% | **−20.0%** | **−2.6%** |
     | `int64_nested` | flat | flat | flat |
   
   
   For others its more like noise
   
     


-- 
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