Repository navigation
perf(fastlanes): answer BitPacked compare and between from the bit width, between through the fused kernel - #10559
Conversation
…dth, between through the fused kernel Signed-off-by: mightsleep <acannix@proton.me>
Merging this PR will regress 2 benchmarks
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | WallTime | filter_neon[8] |
959 ns | 1,108 ns | -13.45% |
| ❌ ℹ️ | Simulation | test_scan_filter[int] |
3.1 ms | 3.5 ms | -11.3% |
| ⚡ | Simulation | fast_lt_out_of_range[16, 65536] |
263 µs | 69.4 µs | ×3.8 |
| ⚡ | Simulation | fast_eq_out_of_range[16, 65536] |
259.5 µs | 75.1 µs | ×3.5 |
| ⚡ | Simulation | fast_eq_out_of_range[4, 65536] |
172.3 µs | 74.7 µs | ×2.3 |
| ⚡ | Simulation | fast_lt_out_of_range[4, 65536] |
158 µs | 70.8 µs | ×2.2 |
| ⚡ | Simulation | new_bp_prim_test_between[i16, 32768] |
217.7 µs | 154.4 µs | +41.03% |
| ⚡ | Simulation | new_bp_prim_test_between[i16, 16384] |
135.8 µs | 104.5 µs | +29.95% |
| ⚡ | Simulation | new_bp_prim_test_between[i32, 32768] |
223.1 µs | 176.1 µs | +26.68% |
| ⚡ | Simulation | new_alp_prim_test_between[f32, 32768] |
225 µs | 179 µs | +25.71% |
| ⚡ | Simulation | new_bp_prim_test_between[i64, 32768] |
240.6 µs | 196.4 µs | +22.5% |
| ⚡ | Simulation | new_alp_prim_test_between[f64, 32768] |
254.9 µs | 210.4 µs | +21.19% |
| ⚡ | Simulation | chunked_opt_bool_canonical_into[(1000, 10)] |
65.7 µs | 55 µs | +19.46% |
| ⚡ | Simulation | new_bp_prim_test_between[i32, 16384] |
138.7 µs | 117 µs | +18.61% |
| ⚡ | WallTime | threshold_avx512[80] |
2.9 µs | 2.5 µs | +16.05% |
| ⚡ | Simulation | new_alp_prim_test_between[f32, 16384] |
164.8 µs | 142.5 µs | +15.7% |
| ⚡ | Simulation | new_bp_prim_test_between[i64, 16384] |
148.9 µs | 130 µs | +14.53% |
| ⚡ | Simulation | new_alp_prim_test_between[f64, 16384] |
162.9 µs | 144.1 µs | +13.03% |
| ⚡ | WallTime | bitpack_blocked_compress_avx2 |
7.6 µs | 6.7 µs | +12.02% |
| ⚡ | WallTime | words_gather_dispatch_neon[65536] |
2 µs | 1.8 µs | +10.77% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing mightsleep:bp-compare-bitwidth (9818b25) with develop (8c2534e)
Footnotes
-
12 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. ↩
Codecov Report❌ Patch coverage is ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
robert3005
left a comment
There was a problem hiding this comment.
Just one comment about allocations. Thanks for the improvement!
…ator Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Robert Kruszewski <github@robertk.io>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Robert Kruszewski <github@robertk.io>
Summary
BitPacked knows its bit width W, so a packed value is in
[0, 2^W - 1]and anything else is a patch. A predicate that is monotone in the value and agrees at both ends of that range is decided for every packed value without unpacking, which is the fast path from #8013 (ty @joseph-isaacs), here extended to between and to patches. Vortex builds for baseline x86-64 by default, where the between path also paid for two compares per value throughstream_predicate.Changes
packed_range.rs: the range of packed values for a bit width, and a constant result with the patched positions fixed up by a dynamic predicate, so it stays one instance per type. Without patches or nulls the result is aConstantArrayand nothing is unpacked.compare: ordering operators are decided when the constant lies outside the packed range;Eq/NotEqonly when it is outside the range or W = 0.between: the same rule on both endpoints, otherwise through the fusedunpack_cmpkernel with the bounds made inclusive and clamped to the packed range, so one unsigned compare of the offset per value regardless of strictness.Benchmarks
Zen 5 laptop, divan medians (minimum over 3 alternating rounds), ratio = develop / branch. Kernel-only counts from
perf statas the difference of--sample-size 400and200.fast_{eq,lt}_out_of_range, 64Kfast_{eq,lt}_out_of_range, 1Knew_bp_prim_test_betweeni16/i32new_bp_prim_test_betweeni64new_alp_prim_test_betweenbaseline_{eq,lt},bitpack_compare_sweepnew_raw_prim_test_between(unaffected)The out-of-range compares now cost the same ~500 ns at any length, which is the fixed
executeoverhead. Kernel instructions drop 2.67x for those and 3.84x for bitpacked between; the in-range compare executes the same instruction count as develop.Checks:
cargo test -p vortex-fastlanes(821 + 4 doctests), clippy clean on the touched files.