Repository navigation
bench(arrow-cast): Add decimal formatting benchmark - #10997
Merged
Merged
Conversation
Add format_decimal.rs, which formats arrays of 8192 random values through ArrayFormatter like format_temporal.rs does, for Decimal32, Decimal64, Decimal128 and Decimal256 at representative precisions and scales, with digit counts that cover values below the scale, values that fit an i128 and the widest Decimal256 values. There was previously no benchmark that covered formatting decimals.
Rich-T-kid
approved these changes
Sep 5, 2026
Jefffrey
approved these changes
Sep 6, 2026
Contributor
|
thanks @neilconway & @Rich-T-kid |
Jefffrey
added a commit
that referenced
this pull request
Sep 6, 2026
# 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; decimal format is unchanged. # AI usage Developed with Claude Code Fable 5.1; reviewed with Codex Astra 6. I reviewed, revised, and understand the resulting code. Co-authored-by: Jeffrey Vo <[email protected]>
Rich-T-kid
pushed a commit
to Rich-T-kid/arrow-rs
that referenced
this pull request
Sep 18, 2026
# Which issue does this PR close? - N/A # Rationale for this change Add `format_decimal.rs`, which formats arrays of 8192 random values through ArrayFormatter like `format_temporal.rs` does, for Decimal32, Decimal64, Decimal128 and Decimal256 at representative precisions and scales, with digit counts that cover values below the scale, values that fit an i128 and the widest Decimal256 values. There was previously no benchmark that covered formatting decimals. # What changes are included in this PR? See above. # Are these changes tested? Yes. # Are there any user-facing changes? No.
Rich-T-kid
pushed a commit
to Rich-T-kid/arrow-rs
that referenced
this pull request
Sep 18, 2026
# 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 (apache#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; decimal format is unchanged. # AI usage Developed with Claude Code Fable 5.1; reviewed with Codex Astra 6. I reviewed, revised, and understand the resulting code. Co-authored-by: Jeffrey Vo <[email protected]>
Rich-T-kid
pushed a commit
to Rich-T-kid/arrow-rs
that referenced
this pull request
Sep 21, 2026
# Which issue does this PR close? - N/A # Rationale for this change Add `format_decimal.rs`, which formats arrays of 8192 random values through ArrayFormatter like `format_temporal.rs` does, for Decimal32, Decimal64, Decimal128 and Decimal256 at representative precisions and scales, with digit counts that cover values below the scale, values that fit an i128 and the widest Decimal256 values. There was previously no benchmark that covered formatting decimals. # What changes are included in this PR? See above. # Are these changes tested? Yes. # Are there any user-facing changes? No.
Rich-T-kid
pushed a commit
to Rich-T-kid/arrow-rs
that referenced
this pull request
Sep 21, 2026
# 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 (apache#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; decimal format is unchanged. # AI usage Developed with Claude Code Fable 5.1; reviewed with Codex Astra 6. I reviewed, revised, and understand the resulting code. Co-authored-by: Jeffrey Vo <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Rationale for this change
Add
format_decimal.rs, which formats arrays of 8192 random values through ArrayFormatter likeformat_temporal.rsdoes, for Decimal32, Decimal64, Decimal128 and Decimal256 at representative precisions and scales, with digit counts that cover values below the scale, values that fit an i128 and the widest Decimal256 values.There was previously no benchmark that covered formatting decimals.
What changes are included in this PR?
See above.
Are these changes tested?
Yes.
Are there any user-facing changes?
No.