neilconway opened a new pull request, #11000:
URL: https://github.com/apache/arrow-rs/pull/11000
# Which issue does this PR close?
- N/A
# Rationale for this change
Display for i256 converted the value to a num-bigint value and formatted
that, which allocates the BigInt's digit vector and runs a generic
arbitrary-precision conversion.
By formatting the value ourselves, we can do better because we don't need to
support arbitrary precision, and we can also avoid the heap allocation and type
conversion overhead.
format_decimal benchmark (#10997), Apple M4 Max:
case before after change
decimal256 (76, 10) 38 digits 1730.13 958.33 -44.6%
decimal256 (76, 10) 76 digits 2088.60 1760.90 -15.7%
The win is bigger for small Decimal256 values because we can do those
entirely in i128; in principle num-bigint could implement a similar
optimization for small values, but it currently does not. Decimal256 values
larger than i128 are split into three chunks and formatted as i128; this is
still faster than going through num-bigint.
In practice, this improves the performance of writing out decimal values as
CSV and JSON, as well as pretty-printing them.
# 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.
--
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]