Skip to content

Keep same-scale decimal widening casts lazy - #11006

Draft
connortsui20 wants to merge 1 commit into
ct/decimal-widen-storedfrom
ct/decimal-widen-lazy-cast
Draft

connortsui20 wants to merge 1 commit into
ct/decimal-widen-storedfrom
ct/decimal-widen-lazy-cast

Conversation

@connortsui20

@connortsui20 connortsui20 commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Tracking Issue: #10701

Top of the decimal Widen stack, on #11005. No release gate.

Summary

A same-scale precision increase copied every value into a wider buffer even when the caller did not need the values yet. Returning a Widen defers that copy and lets subsequent kernels keep working on the narrow child.

Changes

The child retains the source dtype and statistics because its values are unchanged. A cast of a decimal Widen passes to that child. Execution copies into the logical width directly, since yielding another widening cast would return a Widen again. The default-writer test compares round-trip values.

Known cost: the retained benchmarks show slower filtering at precision 38 (see #10946).

Historical local benchmark results

These retained measurements predate this style pass and rebase. They do not measure the current head.

cargo bench -p vortex-array --bench widen_decimal, Apple M4, medians. The numbers were measured at the top of this stack before the split, so they cover the whole stack, not this layer alone. The baseline is the canonical input, and the candidate is the same values as a Widen (child precision 5 under precision 10, 9 under 18, and 18 under 38). CodSpeed on this PR measures the layer itself.

bench p10 canonical p10 Widen p18 canonical p18 Widen p38 canonical p38 Widen
cast_widen 12.08 µs 6.958 µs 12.33 µs 6.958 µs 16.54 µs 14.58 µs

API Changes

A same-scale decimal cast returns a Widen when the target precision grows the canonical width.

@codspeed

codspeed Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Merging this PR will regress 5 benchmarks

1 warning

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

⚡ 10 improved benchmarks
❌ 5 regressed benchmarks
✅ 2345 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ CPU Simulation bench_compare_varbin[(50000, 2)] 132 µs 162 µs -18.49%
❌ CPU Simulation bench_compare_varbin[(50000, 64)] 133.8 µs 163.6 µs -18.23%
❌ CPU Simulation bench_compare_sliced_dict_varbinview[(7500, 10000)] 199.6 µs 227.4 µs -12.24%
❌ CPU Simulation bench_compare_sliced_dict_varbinview[(10000, 10000)] 205.8 µs 233.6 µs -11.93%
❌ CPU Simulation bench_compare_sliced_dict_varbinview[(1000, 10000)] 77.9 µs 87.8 µs -11.31%
⚡ CPU Simulation cast_widen[p38_childp18_widen] 2.9 ms 1.5 ms +95.67%
⚡ Walltime mul_u64_nonnull_neon 39.1 µs 20.2 µs +93.69%
⚡ CPU Simulation widen_nullable[16384] 359 µs 224.9 µs +59.59%
⚡ CPU Simulation cast_widen[p10_childp5_widen] 1,211.4 µs 789.1 µs +53.52%
⚡ CPU Simulation cast_widen[p18_childp9_widen] 1,211.6 µs 789.5 µs +53.47%
⚡ CPU Simulation cast_widen[p38_childp18_canonical] 2.4 ms 1.8 ms +34.16%
⚡ CPU Simulation filter_powerlaw_by_random[10000] 1.6 µs 1.4 µs +16.73%
⚡ CPU Simulation take_filter_primitive_small_uncached_random_mask_random_indices[4096, 10] 23.8 µs 20.9 µs +14.21%
⚡ CPU Simulation cast_widen[p10_childp5_canonical] 1,009 µs 907.4 µs +11.19%
⚡ CPU Simulation cast_widen[p18_childp9_canonical] 1,008.5 µs 907 µs +11.19%

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-lazy-cast (778cd7f) with ct/decimal-widen-stored (b3b006c)

Open in CodSpeed

@connortsui20 connortsui20 added the changelog/performance A performance improvement label Oct 29, 2026
@connortsui20 connortsui20 mentioned this pull request Oct 30, 2026
11 of 32 tasks
@connortsui20
connortsui20 force-pushed the ct/decimal-widen-lazy-cast branch from c0ec9ab to 778cd7f Compare October 30, 2026 17:50
@connortsui20
connortsui20 removed this pull request from stack #11007 October 30, 2026 18:02
@connortsui20
connortsui20 added this pull request to stack #11058 October 30, 2026 18:04
A same-scale cast that grows the canonical width copied every value
into the wider type, even when the caller never reads them all. Return
a decimal Widen over the source instead, whose dtype is a true label
for its values, so the copy waits for execution. The child also keeps
the statistics of the source, such as exact extrema, because it holds
the same values. A cast of a decimal Widen passes to its child.

This is the first production code that builds a decimal Widen. Widen
execution already copies decimal values instead of yielding a cast,
which now also keeps it from yielding a cast that returns a Widen
again. A test checks that the default file writer round-trips a
decimal Widen.

Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
@connortsui20
connortsui20 force-pushed the ct/decimal-widen-lazy-cast branch from 778cd7f to 7819bca Compare October 30, 2026 19:28

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/performance A performance improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant