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

   # Which issue does this PR close?
   
   - N/A
   
   # Rationale for this change
   
   `parse_decimal` validated the parsed value against the precision with 
`is_valid_decimal_precision`, an out-of-line call that loads the bounds for the 
precision and compares the value against both.
   
   The parser already knows how many digits it kept. We can modify the mantissa 
scan to return the digit count and then use this count to skip the precision 
check for the common case that the number of parsed digits implies the parsed 
value is well within the allowed precision.
   
   `parse_decimal` microbenchmark, Apple M4 Max, µs per 1024 inputs:
   
   ```
       case                                 before   after   change
       123.123                                7.93    7.85    -1.0%
       123.1234                              11.39   10.96    -3.7%
       123.1                                 11.22   10.27    -8.5%
       123                                   10.49    9.47    -9.7%
       -123.123                               8.16    8.07    -1.0%
       -123.1234                             11.47   11.09    -3.3%
       -123.1                                11.45   10.53    -8.0%
       -123                                  10.71    9.84    -8.1%
       0.0000123                              8.37    7.89    -5.7%
       12.                                   10.21    9.54    -6.5%
       -12.                                  10.44    9.76    -6.5%
       00.1                                  10.69    9.90    -7.4%
       -00.1                                 10.93   10.00    -8.5%
       12345678912345678.1234                24.49   24.53    +0.1%
       -12345678912345678.1234               24.67   24.77    +0.4%
       99999999999999999.999                 20.31   19.90    -2.0%
       -99999999999999999.999                20.25   20.40    +0.7%
       .123                                   6.34    6.18    -2.6%
       -.123                                  6.59    6.41    -2.7%
       123.                                  10.67   10.12    -5.1%
       -123.                                 10.94   10.30    -5.8%
       string decimal128 short                8.20    7.85    -4.2%
       string decimal128 integer             11.19   10.89    -2.7%
       string decimal128 exact scale         11.43   11.05    -3.3%
       string decimal128 padded scale        10.50   10.42    -0.8%
       string decimal128 rounded scale       15.23   14.63    -3.9%
       string decimal128 signed              15.28   14.78    -3.3%
       string decimal128 38 digits           24.19   23.65    -2.2%
       string decimal128 exponent            20.28   20.18    -0.5%
       string decimal128 negative exponent   19.52   18.79    -3.7%
       string decimal128 negative scale      18.32   17.97    -1.9%
       string decimal128 long fraction       22.39   22.14    -1.1%
       string decimal256 76 digits           59.03   57.76    -2.1%
       string decimal256 rounded scale       55.72   54.71    -1.8%
       string decimal32 short                 8.51    7.74    -9.1%
       string decimal32 9 digits             10.45    9.76    -6.6%
       string decimal64 short                 7.29    6.84    -6.2%
       string decimal64 18 digits            12.04   11.66    -3.2%
   ```
   
   # What changes are included in this PR?
   
   See above.
   
   # Are these changes tested?
   
   Yes; new test added, existing tests pass.
   
   # Are there any user-facing changes?
   
   No.
   
   # AI usage
   
   Developed with Claude Code Fable 5.1; reviewed with Codex Astra 6. I 
reviewed, revised, and understand the resulting code.


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