Mola-maker opened a new pull request, #12327:
URL: https://github.com/apache/arrow-rs/pull/12327

   Closes #12326
   
   # Rationale for this change
   
   `DecimalType::is_valid_decimal_precision` is called once per value, and the 
four implementations in `arrow-array` are not `#[inline]`. They are not 
generic, so a caller in another crate depends on LTO to inline them. The issue 
reports that in DataFusion Comet the call stays out of line even in release 
builds with thin LTO, with the grouped decimal SUM/AVG accumulators 10-37% 
slower when the call is forced out of line.
   
   # What changes are included in this PR?
   
   Adds `#[inline]` to the four `is_valid_decimal_precision` implementations 
(`Decimal32Type`, `Decimal64Type`, `Decimal128Type`, `Decimal256Type`) in 
`arrow-array/src/types.rs`.
   
   # Are these changes tested?
   
   No new tests: the change is an inlining hint only and does not change 
behavior, so there is no observable behavior a regression test could assert. 
The existing decimal test suites pass unchanged (arrow-array 29 passed, 
arrow-cast 20 passed, arrow-data 2 passed; `cargo fmt --check` and `cargo 
clippy -p arrow-array --all-targets --all-features` clean).
   
   The inlining effect was verified directly with a small out-of-tree release 
binary calling `<Decimal128Type as DecimalType>::is_valid_decimal_precision` 
per value (no LTO): before this change the caller contained an out-of-line call 
to the trait method; after, the caller contains no call at all and the bounds 
check (precision <= 38 plus the MIN/MAX table lookups) is inlined.
   
   Before: the caller contains an out-of-line call to the trait method
   <img width="781" height="175" alt="arrow-rs-12326-verify-before" 
src="https://github.com/user-attachments/assets/aa2ba1af-6a88-4857-adb1-f9836e105d1f";
 />
   
   After: the caller contains no call; the bounds check is inlined, and the 
decimal test suites pass
   <img width="628" height="280" alt="arrow-rs-12326-verify-after" 
src="https://github.com/user-attachments/assets/80ed88dc-41cf-45df-9ce5-d822afd4264d";
 />
   
   # Are there any significant user-facing changes?
   
   No.
   
   # AI usage disclosure
   
   AI assistance was used for verification and drafting; the change itself is 
the four `#[inline]` attributes requested in the issue.


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