Skip to content

perf(fastlanes): answer BitPacked compare and between from the bit width, between through the fused kernel - #10559

Merged
robert3005 merged 3 commits into
vortex-data:developfrom
mightsleep:bp-compare-bitwidth
Oct 19, 2026
Merged

robert3005 merged 3 commits into
vortex-data:developfrom
mightsleep:bp-compare-bitwidth

Conversation

@mightsleep

Copy link
Copy Markdown
Contributor

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 through stream_predicate.

Changes

  • New 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 a ConstantArray and nothing is unpacked.
  • compare: ordering operators are decided when the constant lies outside the packed range; Eq/NotEq only when it is outside the range or W = 0.
  • between: the same rule on both endpoints, otherwise through the fused unpack_cmp kernel with the bounds made inclusive and clamped to the packed range, so one unsigned compare of the offset per value regardless of strictness.
  • Tests for both against the decoded reference, including patches, nulls, W = 0 and full width.

Benchmarks

Zen 5 laptop, divan medians (minimum over 3 alternating rounds), ratio = develop / branch. Kernel-only counts from perf stat as the difference of --sample-size 400 and 200.

bench default target-cpu=native
fast_{eq,lt}_out_of_range, 64K 8.8 to 11.8x 4.9 to 5.6x
fast_{eq,lt}_out_of_range, 1K 1.09 to 1.14x 0.97 to 1.01x
new_bp_prim_test_between i16/i32 2.0 to 6.2x 1.3 to 3.3x
new_bp_prim_test_between i64 1.3 to 1.55x 1.26 to 1.97x
new_alp_prim_test_between 1.24 to 3.7x 1.18 to 2.5x
baseline_{eq,lt}, bitpack_compare_sweep 0.97 to 1.03x 0.99 to 1.03x
new_raw_prim_test_between (unaffected) 1.01 to 1.03x 0.99 to 1.01x

The out-of-range compares now cost the same ~500 ns at any length, which is the fixed execute overhead. 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.

…dth, between through the fused kernel

Signed-off-by: mightsleep <acannix@proton.me>
@joseph-isaacs joseph-isaacs added action/bench-sql Run SQL benchmarks without Vortex Compact on this PR changelog/performance A performance improvement labels Oct 16, 2026
@codspeed

codspeed Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Merging this PR will regress 2 benchmarks

⚠️ 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.

⚠️ 1 benchmark measured no execution time

Nothing ran under measurement, usually because the compiler removed the code under test. This result is not comparable, so it counts as unchanged.

Preventing compiler optimizations

⚠️ 16 benchmarks spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

ℹ️ 40 benchmarks have no flame graph

The flamegraph could not be generated because we failed to resolve the symbols in the profiling trace. This happens when we fail to harvest information about language frames.

⚠️ 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

⚡ 18 improved benchmarks
❌ 2 regressed benchmarks
✅ 2388 untouched benchmarks
⏩ 12 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

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)

Open in CodSpeed

Footnotes

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

codecov Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.54902% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.01%. Comparing base (6eae823) to head (a2b06cd).
⚠️ Report is 32 commits behind head on develop.

Files with missing lines Patch % Lines
...odings/fastlanes/src/bitpacking/compute/between.rs 97.26% 2 Missing ⚠️
.../fastlanes/src/bitpacking/compute/compare_fused.rs 71.42% 2 Missing ⚠️
...s/fastlanes/src/bitpacking/compute/packed_range.rs 96.87% 1 Missing ⚠️

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@robert3005 robert3005 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@robert3005
robert3005 enabled auto-merge (squash) October 19, 2026 18:01
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Robert Kruszewski <github@robertk.io>
@robert3005
robert3005 merged commit 61ff28d into vortex-data:develop Oct 19, 2026
84 of 86 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action/bench-sql Run SQL benchmarks without Vortex Compact on this PR changelog/performance A performance improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants