Repository navigation
Build DecimalByteParts from the canonical decimal array - #10992
Draft
connortsui20 wants to merge 4 commits into
Draft
connortsui20 wants to merge 4 commits into
connortsui20 wants to merge 4 commits into
Conversation
This was referenced Oct 29, 2026
Merging this PR will improve performance by 25.32%2 warnings
Performance Changes
Tip Curious why performance improved? Comment Comparing |
connortsui20
force-pushed
the
ct/dbp-scheme-canonical
branch
from
October 29, 2026 20:21
d918e63 to
883898f
Compare
The decimal scheme is about to start from the canonical array instead of a narrowed copy. These entries pin what it writes today, so the change shows up as snapshot churn: a wide dtype with small values, a nullable column, negative values, a precision-40 column whose values fit i128, and null slots that hold values far outside the valid range. Signed-off-by: Connor Tsui <[email protected]>
`split_decimal` chose the lower-part count from the storage width, so an i128 or i256 array always got one or three lower parts, even when every valid value fits i64. The btrblocks scheme worked around this with `narrowed_decimal`, which narrows by every slot, nulls included. A large value in a null slot can then force more lower parts than the constructor allows, and a narrow `DecimalArray` will soon be illegal. `lower_part_count` now scans the valid values: 0 when they fit i64, 1 when they fit i128, and 3 otherwise. It avoids the decimal `min_max` aggregate, which panics on a value outside the precision. `split_decimal` takes the count, and returns an error when a valid value does not fit it or the storage width does not support it. `DecimalByteParts::encode` combines the two. Signed-off-by: Connor Tsui <[email protected]>
The btrblocks decimal scheme split a copy from `narrowed_decimal`, which narrows by every slot, nulls included, and a narrow `DecimalArray` will soon be illegal. The scheme now splits the canonical array with the count from `lower_part_count`. In v1 mode, an array that needs lower parts stays canonical. Without lower parts, the MSP narrows through `WidenArray::encode_values`, which keeps it signed as the constructor requires. File contents stay the same with two accepted changes. In v1 mode, precision 39 to 76 with values from 65 to 128 bits is written as a canonical i256 array instead of an i128 one. Large values in null slots no longer widen the MSP. The golden snapshots of `decimal_wide_p40` and `decimal_null_slot_values` show both. Signed-off-by: Connor Tsui <[email protected]>
The btrblocks decimal scheme was its only caller, and it now starts from the canonical array. A narrowed `DecimalArray` will soon be illegal, so nothing should build one. Signed-off-by: Connor Tsui <[email protected]>
connortsui20
force-pushed
the
ct/dbp-scheme-canonical
branch
from
October 29, 2026 21:33
883898f to
53dd750
Compare
This branch has not been deployed
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.
Tracking Issue: #10701
Stacked on #10905. Merge this right after #10905, which itself waits for 0.91.0 to publish the CD2 compat fixtures. Without #10905 underneath, an
i128array whose values fiti64would get no lower parts and decode at the MSP width.Summary
The btrblocks decimal scheme copied each array into
narrowed_decimal, the narrowest width that holds every slot (null slots included), and split it by that stored width. A large value in a null slot could then force lower parts that the lower-part bound of #10905 rejects. The narrowDecimalArraythat the copy builds also becomes illegal once everyDecimalArraymust have the canonical width of its dtype. The scheme now starts from the canonical array and chooses the lower parts from the valid values only.Changes
lower_part_countreturns how many lower parts the valid values need: 0 when they fiti64, 1 when they fiti128, and 3 otherwise. It usesvalid_rangeinstead of the decimalmin_maxaggregate, because that aggregate builds decimal scalars, which panic on a value outside the precision.split_decimaltakes that count, so a wide array whose values fiti64copies into ani64MSP, and ani256array whose values fiti128splits into one lower part.WidenArray::encode_values(with aTODO(connor)[Widen]on whether it should become aWiden).narrowed_decimalis removed, since the scheme was its only caller.The first commit adds golden entries on the old scheme, so the snapshot diff shows exactly what changes on disk. Only two entries change, and both are accepted:
decimal_wide_p40: since the decimal is no longer narrowed, v1 mode writes precision 39 to 76 with values that need 65 to 128 bits as a canonicali256array instead of ani128one.decimal_null_slot_values: large values in null slots no longer widen the MSP, which goes fromi64toi32.API Changes
Adds
vortex_decimal_byte_parts::lower_part_count.split_decimaltakes the lower-part count and returns an error for a count that a valid value does not fit, or for a shape it does not support. Removesvortex_array::arrays::decimal::narrowed_decimal.