perf: specialize grouped sums for constant arrays - #9822
Conversation
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
Merging this PR will regress 3 benchmarks
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | WallTime | arrow_checked_add_u32_neon[16384] |
13.4 µs | 20.3 µs | -34.07% |
| ❌ | Simulation | decompress[u64, (4000, 1024)] |
70.8 µs | 86 µs | -17.7% |
| ❌ | WallTime | mul_u32_nonnull_avx512 |
5.5 µs | 6.2 µs | -10.08% |
| ⚡ | WallTime | mul_u64_nonnull_neon |
20.6 µs | 15.1 µs | +36.24% |
| ⚡ | WallTime | multiply_shapes_neon[(16384, PerRowPerRow)] |
20.3 µs | 17.2 µs | +17.98% |
| ⚡ | WallTime | mul_i64_nonnull_neon |
20.2 µs | 17.2 µs | +17.71% |
| ⚡ | WallTime | filtered_owned_i64_avx512[OneNullInEight] |
26.3 µs | 22.4 µs | +17.12% |
| ⚡ | Simulation | allocate_drop_arrow[0] |
456.9 ns | 402.7 ns | +13.45% |
| ⚡ | WallTime | mul_i32_nonnull_avx512 |
7.9 µs | 7.1 µs | +10.34% |
| 🆕 | Simulation | sum_v2_constant_fixed[false, 128] |
N/A | 1.4 ms | N/A |
| 🆕 | Simulation | sum_v2_constant_fixed[false, 2] |
N/A | 82.6 ms | N/A |
| 🆕 | Simulation | sum_v2_constant_fixed[true, 128] |
N/A | 168 µs | N/A |
| 🆕 | Simulation | sum_v2_constant_fixed[true, 2] |
N/A | 229 µs | N/A |
| 🆕 | Simulation | sum_v2_constant_list[false] |
N/A | 1.4 ms | N/A |
| 🆕 | Simulation | sum_v2_constant_list[true] |
N/A | 1.2 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 ct/sum-constant (f185f49) with develop (e3b8eb2)
Footnotes
-
218 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. ↩
Summary
Reuses one sum partial for fixed-size lists of primitive constant elements. Variable-size groups reuse the existing whole-array accumulator without slicing the elements.
Changes
Uses the existing
SumandSumV2accumulation paths for nulls, NaNs, overflow, and signed zero, with focused tests for grouped behavior. Whole-array arithmetic and decimal handling remain unchanged.Validation
cargo nextest run -p vortex-array --lib: 3,462 passed, 1 skipped.cargo test --doc -p vortex-array: passed.cargo clippy --all-targets --all-features -- -D warnings: passed.vortex-duckdbandvortex-ffi, outside this PR.Benchmark results
Local
aarch64-apple-darwinmedians with Rust 1.98.0 and 100 samples, usingcargo bench -p vortex-array --bench aggregate_grouped -- sum_v2_constant --sample-count 100. Both modes usef185f493f4be4568e82d75fb8869f460e25e1c0f, with the baseline disabling the constant grouped kernel. Timings include finalization to a primitive array.Fixed-size inputs contain 16,384
i32values. The list-view input has 128 groups with sizes from 1 to 15.