Skip to content

Keep same-scale decimal widening casts lazy - #11006

Merged
connortsui20 merged 2 commits into
developfrom
ct/decimal-widen-lazy-cast
Nov 4, 2026
Merged

connortsui20 merged 2 commits into
developfrom
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.

Basically, we might as well keep things in Widen form instead of casting immediately.

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 improve performance by 52.78%

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

⚡ 1 improved benchmark
✅ 1764 untouched benchmarks
🆕 3 new benchmarks
⏩ 130 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
⚡ CPU Simulation widen_nullable[16384] 364.1 µs 238.3 µs +52.78%
🆕 CPU Simulation cast_lazy[p38_childp18_canonical] N/A 25.8 µs N/A
🆕 CPU Simulation cast_lazy[p38_childp18_widen] N/A 23.8 µs N/A
🆕 CPU Simulation cast_execute N/A 273.8 µs N/A

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing ct/decimal-widen-lazy-cast (9b68f5a) with develop (dd2eede)

Open in CodSpeed

Footnotes

  1. 130 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. ↩

@connortsui20 connortsui20 added the changelog/performance A performance improvement label Oct 29, 2026
@connortsui20 connortsui20 mentioned this pull request Oct 30, 2026
20 of 34 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
@connortsui20
connortsui20 force-pushed the ct/decimal-widen-lazy-cast branch 3 times, most recently from c63777d to f0c5f99 Compare November 2, 2026 16:57
@connortsui20
connortsui20 removed this pull request from stack #11058 November 2, 2026 16:59
@connortsui20
connortsui20 added this pull request to stack #11104 November 2, 2026 16:59
@connortsui20
connortsui20 force-pushed the ct/decimal-widen-lazy-cast branch from f0c5f99 to d7148e8 Compare November 2, 2026 17:08
@connortsui20
connortsui20 force-pushed the ct/decimal-widen-lazy-cast branch 3 times, most recently from a1561b3 to a47042b Compare November 2, 2026 19:52
@connortsui20
connortsui20 force-pushed the ct/decimal-widen-lazy-cast branch 2 times, most recently from c408380 to 2a0bb0e Compare November 2, 2026 21:29
@connortsui20
connortsui20 force-pushed the ct/decimal-widen-lazy-cast branch from 2a0bb0e to da3eab3 Compare November 3, 2026 13:20
@connortsui20
connortsui20 force-pushed the ct/decimal-widen-lazy-cast branch 2 times, most recently from 0ed30bc to 1bad4e5 Compare November 3, 2026 14:22
@connortsui20
connortsui20 force-pushed the ct/decimal-widen-lazy-cast branch 2 times, most recently from 2f1c268 to 42f6d55 Compare November 3, 2026 15:12
@connortsui20
connortsui20 force-pushed the ct/decimal-widen-lazy-cast branch from 42f6d55 to 89ce253 Compare November 3, 2026 16:31
@connortsui20
connortsui20 force-pushed the ct/decimal-widen-lazy-cast branch from 89ce253 to ff3c6f3 Compare November 3, 2026 16:46
@connortsui20
connortsui20 force-pushed the ct/decimal-widen-lazy-cast branch from ff3c6f3 to 76ae246 Compare November 3, 2026 21:25
Base automatically changed from ct/decimal-widen-stored to develop November 4, 2026 13:53
@joseph-isaacs
joseph-isaacs force-pushed the ct/decimal-widen-lazy-cast branch from 76ae246 to a34855c Compare November 4, 2026 13:53
@connortsui20
connortsui20 marked this pull request as ready for review November 4, 2026 16:33
@connortsui20
connortsui20 force-pushed the ct/decimal-widen-lazy-cast branch 2 times, most recently from cbdec26 to 916a6f7 Compare November 4, 2026 17:00
Return a Widen when a same-scale decimal cast increases the canonical
width, so callers can defer the copy until execution. Preserve the
source dtype, value buffer, and statistics on the child, and pass
subsequent decimal Widen casts through to that child.

Cover width changes, noncanonical storage, nullability, statistics,
repeated casts, and the default writer round trip. Consolidate the
older precision-growth and buffer-reuse tests into the parameterized
coverage.

Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
Keep canonical and Widen inputs for lazy construction, and one
end-to-end canonical cast for execution into i256 values. Avoid a
second end-to-end case that overlaps the construction and execution
coverage. Update the CodSpeed target count to match the nine cases.

Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
@connortsui20
connortsui20 force-pushed the ct/decimal-widen-lazy-cast branch from 916a6f7 to 9b68f5a Compare November 4, 2026 17:17
@connortsui20
connortsui20 enabled stacked auto-merge (squash) November 4, 2026 17:22
@connortsui20
connortsui20 merged commit e72a61d into develop Nov 4, 2026
73 checks passed
@connortsui20
connortsui20 deleted the ct/decimal-widen-lazy-cast branch November 4, 2026 17:44
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.

2 participants