Skip to content

Accept decimal children in Widen - #10946

Draft
connortsui20 wants to merge 7 commits into
ct/decimal-interleavefrom
ct/decimal-widen
Draft

connortsui20 wants to merge 7 commits into
ct/decimal-interleavefrom
ct/decimal-widen

Conversation

@connortsui20

@connortsui20 connortsui20 commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Summary

A decimal dtype's canonical width can be much wider than its values need. Decimal Widen stores them in a lower-precision child, so compatible operations can avoid decoding the parent-width buffer.

Changes

Choose the child precision from valid values and scale. Push comparisons, bounds, fitting fills and ordered aggregates to the child where they preserve the canonical result. Decimal sums keep the parent accumulator precision. Execution copies decimal values directly, so a widening cast that returns another Widen cannot create an execution loop.

Widen stays in memory and outside ArraySession. The default writer already executes it through its pipeline, so CD4 adds no serialization lowering. Round-trip tests cover that path, alongside kernel, fallback and conformance tests. Benchmarks compare canonical and Widen inputs across three precision pairs.

API Changes

Casting a DecimalArray to a higher precision at the same scale returns Widen when the canonical width grows. Add WidenArray::encode_decimal and the shared smallest_decimal_dtype helper.

@connortsui20 connortsui20 added the changelog/feature A new feature label Oct 28, 2026
@codspeed

codspeed Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 27.52%

2 warnings

⚠️ Walltime results may be unreliable

Some benchmarks used the Walltime instrument outside CodSpeed Macro Runners, which can make the results inconsistent.

Learn more about Macro Runners

See affected benchmarks

⚠️ 4 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚡ 6 improved benchmarks
❌ 7 regressed benchmarks
✅ 2261 untouched benchmarks
🆕 42 new benchmarks
⏩ 370 skipped benchmarks1
🗄️ 30 archived benchmarks run2

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ CPU Simulation filter_powerlaw_by_random[10000] 670 ns 31,971 ns -97.9%
❌ Walltime mul_u64_nonnull_neon 20.1 µs 40 µs -49.79%
❌ CPU Simulation bench_compare_varbin[(50000, 2)] 133.8 µs 162 µs -17.37%
❌ CPU Simulation bench_compare_varbin[(50000, 64)] 135.6 µs 163.9 µs -17.31%
❌ CPU Simulation bench_compare_sliced_dict_varbinview[(7500, 10000)] 200.8 µs 227.7 µs -11.78%
❌ CPU Simulation bench_compare_sliced_dict_varbinview[(10000, 10000)] 207 µs 233.8 µs -11.47%
❌ CPU Simulation bench_compare_sliced_dict_varbinview[(1000, 10000)] 79.9 µs 90.2 µs -11.37%
⚡ CPU Simulation widen_nullable[16384] 359.4 µs 224.8 µs +59.88%
⚡ CPU Simulation random_i8[0.01] 123.3 µs 98.9 µs +24.66%
⚡ CPU Simulation take[(16, 8, 1)] 119.5 µs 106.2 µs +12.56%
⚡ CPU Simulation max_f64 315.2 µs 281.2 µs +12.07%
⚡ Walltime add_constant_shapes_neon[(32768, PerRowConstant)] 15.7 µs 14.2 µs +10.57%
⚡ Walltime add_constant_shapes_neon[(32768, ConstantPerRow)] 15.7 µs 14.2 µs +10.19%
🆕 CPU Simulation cast_widen[p10_childp5_canonical] N/A 913.8 µs N/A
🆕 CPU Simulation cast_widen[p10_childp5_widen] N/A 789.7 µs N/A
🆕 CPU Simulation cast_widen[p18_childp9_canonical] N/A 913.3 µs N/A
🆕 CPU Simulation cast_widen[p18_childp9_widen] N/A 790.1 µs N/A
🆕 CPU Simulation cast_widen[p38_childp18_canonical] N/A 1.8 ms N/A
🆕 CPU Simulation cast_widen[p38_childp18_widen] N/A 1.5 ms N/A
🆕 CPU Simulation compare_constant_out_of_range[p10_childp5_canonical] N/A 307.3 µs N/A
... ... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing ct/decimal-widen (9577faf) with ct/decimal-interleave (c0eb004)

Open in CodSpeed

Footnotes

  1. 370 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. 30 benchmarks were run, but are now archived. If they were deleted in another branch, consider rebasing to remove them from the report. Instead if they were added back, click here to restore them. ↩

@connortsui20
connortsui20 force-pushed the ct/decimal-interleave branch from 98dea22 to bd15c87 Compare October 28, 2026 20:00
@connortsui20
connortsui20 force-pushed the ct/decimal-widen branch 3 times, most recently from 9b2b581 to 31f7451 Compare October 28, 2026 20:41
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
Move decimal execution into its own function, with a note on why it copies
instead of yielding a cast. The leaf cast compares canonical widths directly
and says which casts reduce without execution. `smallest_decimal_dtype` takes a
`RangeInclusive`, like `smallest_integer_ptype`. The two-`Widen` compare test
now covers children with different canonical widths.

Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/feature A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant