alamb opened a new pull request, #10893:
URL: https://github.com/apache/arrow-rs/pull/10893

   # Which issue does this PR close?
   
   - Part of the binary-size / LLVM IR reduction effort started in #10889.
   
   # Rationale for this change
   
   `From<PrimitiveArray<T>> for ArrayData` (reached via `Array::to_data` / 
`into_data`) is monomorphized for all ~32 primitive types in every crate that 
calls it — ~156 lines of LLVM IR per copy, ~5,000 lines per consumer crate 
(arrow-cast, arrow-ord, arrow-select, arrow-row, parquet, ...). After 
extracting the untyped `Buffer`, the conversion is identical for every type, so 
almost all of that is duplicated code.
   
   # What changes are included in this PR?
   
   Move the `ArrayDataBuilder` construction into a private non-generic 
`primitive_to_array_data(data_type, len, values, nulls)` helper, compiled once 
in `arrow-array`. The generic `From` impl just destructures the array and calls 
it. Still statically dispatched — no behavior or performance change.
   
   Measured with `cargo llvm-lines --release -p arrow-row --lib` 
(cargo-llvm-lines 0.4.41, aarch64-apple-darwin); other consumer crates have 
near-identical numbers:
   
   | | before | after |
   |---|---:|---:|
   | `From<PrimitiveArray<T>> for ArrayData` IR in arrow-row | 4,992 lines / 32 
copies | 1,952 lines / 32 thin shims **(−61%)** |
   
   The same pattern applies to the byte/list array `From` impls (far fewer 
instantiations each); those can be follow-ups if this approach is agreeable.
   
   # Are these changes tested?
   
   Covered by existing tests (`to_data`/`into_data` round-trips are exercised 
throughout the test suite).
   
   # Are there any user-facing changes?
   
   No. The helper is private and the produced `ArrayData` is identical.


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

Reply via email to