Skip to content

refactor(decimal): dispatch numeric kernels on one storage width - #9756

Merged
mhk197 merged 1 commit into
developfrom
mk/decimal-kernel-monomorphization
Sep 3, 2026
Merged

refactor(decimal): dispatch numeric kernels on one storage width#9756
mhk197 merged 1 commit into
developfrom
mk/decimal-kernel-monomorphization

Conversation

@mhk197

@mhk197 mhk197 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

checked_decimal_arrays is generic over the working width (6 types) and the operator (4), so there are 24 copies of the outer function. Inside each copy, a match_each_decimal_value_type! on the lhs storage type nests another on the rhs storage type, so every copy contains 36 checked_lanes closures. The 24 outer functions plus their 24 × 36= 864 closures make instantiations.

The nesting exists because a DecimalArray's storage width is independent of its precision, so two operands sharing a DecimalDType may still be stored at different widths.

Instead, this PR dispatches on a single storage width. A mismatched pair is first widened to the wider of the two with the existing widened_buffer (zero-copy when they already match), and the lane loop then runs once per (working width, operator, storage width) with the same inline checked cast as before.

Mono items in vortex-array (cargo +nightly rustc -p vortex-array --lib -- -Zprint-mono-items):

before after
checked_decimal_arrays 888 168
numeric::decimal::* module total 1,372 652
lane_kernels::* total 15,544 9,694
whole crate 100,083 93,513

Matched-storage inputs take the code path they did before, so the binary_ops decimal benchmarks are unchanged within noise.

@mhk197 mhk197 changed the title refactor(decimal): dispatch numeric kernels on one storage width (888 → 168 instantiations) refactor(decimal): dispatch numeric kernels on one storage width Sep 3, 2026
@codspeed-hq

codspeed-hq Bot commented Sep 3, 2026

Copy link
Copy Markdown

Merging this PR will regress 1 benchmark

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 5 improved benchmarks
❌ 1 regressed benchmark
✅ 2175 untouched benchmarks
⏩ 206 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation random_i8[0.5] 67.2 µs 91.3 µs -26.37%
Simulation random_i16[0.8] 92.1 µs 74.4 µs +23.81%
Simulation compact_sliced[(1024, 90)] 1.5 µs 1.3 µs +16.67%
Simulation compact_sliced[(2048, 90)] 1.6 µs 1.4 µs +15.95%
WallTime mul_u32_nonnull_avx512 6.3 µs 5.6 µs +11.72%
Simulation allocate_drop_bytes[0] 520.2 ns 466 ns +11.62%

Tip

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


Comparing mk/decimal-kernel-monomorphization (8927d20) with develop (dab1684)

Open in CodSpeed

Footnotes

  1. 206 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.

@mhk197
mhk197 marked this pull request as ready for review September 3, 2026 18:08
@mhk197 mhk197 added the changelog/chore A trivial change label Sep 3, 2026
@mhk197
mhk197 requested a review from robert3005 September 3, 2026 18:09
@mhk197
mhk197 enabled auto-merge (squash) September 3, 2026 20:29
@mhk197
mhk197 merged commit bfaebe0 into develop Sep 3, 2026
108 of 111 checks passed
@mhk197
mhk197 deleted the mk/decimal-kernel-monomorphization branch September 3, 2026 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/chore A trivial change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants