Skip to content

Decimal Mul/Div kernels - #9221

Merged
mhk197 merged 8 commits into
developfrom
mk/decimal-mul-div
Aug 7, 2026
Merged

Decimal Mul/Div kernels#9221
mhk197 merged 8 commits into
developfrom
mk/decimal-mul-div

Conversation

@mhk197

@mhk197 mhk197 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Adds native Mul and Div execution for decimal arrays, completing the operator set that #8724 started with Add/Sub.

operator result precision result scale
Add, Sub p + 1 s
Mul 2p + 1 2s
Div p + s + 4 s + 4

Execution

Lanes run at a working width from decimal_numeric_work_dtype, then narrow to the result's own storage width. The two widths are not always the same: Mul's intermediate is the result itself, but Div scales the dividend by 10^result_scale before dividing and so needs room for p + |result_scale| digits. A negative result scale scales the divisor instead.

DecimalOpConstants<W> hoists the per-execution constants — the result-precision bounds and the two division scale factors — out of the lane loop.

Every lane is checked at the working width. DecimalArray does not validate its stored values against the declared precision, so an out-of-precision value can reach a kernel and must not be able to overflow it; test_decimal_value_outside_working_width_errors has depended on that behaviour since #8724. Overflowing the result precision on a valid lane is an error, as is division by zero; invalid lanes never error.

@mhk197 mhk197 added the changelog/feature A new feature label Aug 5, 2026
@codspeed-hq

codspeed-hq Bot commented Aug 5, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 3.86%

⚡ 1 improved benchmark
❌ 1 regressed benchmark
✅ 1923 untouched benchmarks
🆕 4 new benchmarks
⏩ 51 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation decode_varbin[(1000, 2)] 61.8 µs 77.8 µs -20.61%
Simulation slice_dict_tight_loop[10000] 812.1 µs 697.5 µs +16.43%
🆕 Simulation mul_decimal_i64_nonnull N/A 415.4 µs N/A
🆕 Simulation div_decimal_i128_nullable N/A 4.4 ms N/A
🆕 Simulation div_decimal_i64_nonnull N/A 943.6 µs N/A
🆕 Simulation mul_decimal_i128_nullable N/A 2.1 ms N/A

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-mul-div (ad8336d) with develop (68e0e58)2

Open in CodSpeed

Footnotes

  1. 51 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. No successful run was found on develop (5047c16) during the generation of this report, so 68e0e58 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@mhk197 mhk197 linked an issue Aug 5, 2026 that may be closed by this pull request
@mhk197
mhk197 marked this pull request as ready for review August 6, 2026 00:21
@robert3005

Copy link
Copy Markdown
Contributor

I think we should make codspeed tests slightly smaller

@mhk197
mhk197 force-pushed the mk/decimal-mul-div branch 2 times, most recently from d6301ef to d68078b Compare August 6, 2026 17:12
@mhk197
mhk197 force-pushed the mk/decimal-mul-div branch from d68078b to e34ca33 Compare August 6, 2026 18:43
@mhk197 mhk197 closed this Aug 7, 2026
@mhk197 mhk197 reopened this Aug 7, 2026
Base automatically changed from mk/decimal-scalar-mul-div to develop August 7, 2026 02:34
mhk197 added 8 commits August 6, 2026 19:34
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
@mhk197
mhk197 force-pushed the mk/decimal-mul-div branch from ee1a14d to ad8336d Compare August 7, 2026 02:34
@mhk197
mhk197 merged commit 4e3be5b into develop Aug 7, 2026
73 of 74 checks passed
@mhk197
mhk197 deleted the mk/decimal-mul-div branch August 7, 2026 02:44
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.

Decimal Arithmetic

3 participants