Skip to content

Push decimal byte parts aggregates into the integer MSP - #11302

Open
connortsui20 wants to merge 1 commit into
developfrom
ct/dbp-aggregates
Open

connortsui20 wants to merge 1 commit into
developfrom
ct/dbp-aggregates

Conversation

@connortsui20

Copy link
Copy Markdown
Member

Summary

DecimalByteParts has no kernels for min_max, min, max, is_sorted, or sum, so each of them decodes the whole array into a DecimalArray before it aggregates. When there are no lower parts, the MSP already holds the unscaled decimal values, so the integer aggregate over the MSP gives the same answer without the decode. This matters more after CD5, where a narrow MSP becomes an integer Widen. Pushing the aggregate into the MSP then lands in Widen's own aggregate kernels, which run on the narrow child, instead of widening the MSP into a new buffer and then building a decimal from it.

Changes

The integer results are relabeled as decimals with DecimalValue::from(i64) instead of Scalar::cast, because an integer-to-decimal cast multiplies by 10^scale, which is wrong for unscaled values. The tests run every case at scale 0 and scale 2 to catch exactly that.

sum only runs on the Stat::Sum path, because only that path sums each batch from zero, and the other paths add to a running total that can overflow at a different point. A null integer sum means i64 overflow, so the kernel declines and the accumulator falls back to the decimal sum. Follow-up: predict overflow from the dtypes and the batch length (like is_exact_sum in Widen), so a batch that is bound to overflow skips the integer pass.

Arrays with lower parts always decline, since their values span several parts and the MSP alone doesn't order or sum them. Every test compares the partial and the dispatched result with the same aggregate on the decoded DecimalArray, including nulls, empty and all-null batches, out-of-precision values, and integer overflow. CodSpeed's dbp_compute sum and min_max cases measure the change.

@connortsui20 connortsui20 added the changelog/performance A performance improvement label Nov 6, 2026
@connortsui20
connortsui20 marked this pull request as ready for review November 6, 2026 16:54
@codspeed

codspeed Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Merging this PR will regress 1 benchmark

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

⚡ 7 improved benchmarks
❌ 1 regressed benchmark
✅ 1909 untouched benchmarks
⏩ 47 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Walltime compare_u64_avx512 3.3 µs 3.8 µs -13.34%
⚡ CPU Simulation sum[gap_msp_i16_p10] 83.3 µs 59.2 µs +40.72%
⚡ CPU Simulation sum[msp_i32_p18] 97.2 µs 73.6 µs +32.08%
⚡ CPU Simulation min_max[gap_msp_i16_p10] 108.6 µs 84.2 µs +29.07%
⚡ CPU Simulation min_max[msp_i32_p18] 130.6 µs 103.3 µs +26.39%
⚡ CPU Simulation min_max[msp_i64_p18_canonical] 155.7 µs 132.1 µs +17.9%
⚡ CPU Simulation min_max[msp_i64_p38] 155.9 µs 132.9 µs +17.33%
⚡ Walltime random_rotating_avx512[(0.5, 0.5, "self_50pct_mask_50pct")] 9.1 µs 8.2 µs +11.53%

Tip

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


Comparing ct/dbp-aggregates (d98aa59) with develop (0fee7df)

Open in CodSpeed

Footnotes

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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant