Skip to content

Implement compare/between for bitpacked arrays - improve performance by up to 2X#7279

Draft
AdamGS wants to merge 14 commits intodevelopfrom
adamg/bitpack-compare
Draft

Implement compare/between for bitpacked arrays - improve performance by up to 2X#7279
AdamGS wants to merge 14 commits intodevelopfrom
adamg/bitpack-compare

Conversation

@AdamGS
Copy link
Copy Markdown
Contributor

@AdamGS AdamGS commented Apr 3, 2026

After some iterations, this seems to improve performance in any case we actually measure. It does require merging and releasing spiraldb/fastlanes#125.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 3, 2026

Merging this PR will degrade performance by 10.6%

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

⚡ 20 improved benchmarks
❌ 2 regressed benchmarks
✅ 1108 untouched benchmarks
⏩ 33 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation new_alp_prim_test_between[f64, 32768] 250.6 µs 117.6 µs ×2.1
Simulation new_bp_prim_test_between[i16, 16384] 89.1 µs 63.4 µs +40.56%
Simulation new_alp_prim_test_between[f64, 2048] 71.6 µs 54.8 µs +30.57%
Simulation new_bp_prim_test_between[i16, 32768] 134.1 µs 91.6 µs +46.46%
Simulation patched_take_10k_adversarial 258.4 µs 228.4 µs +13.14%
Simulation new_bp_prim_test_between[i16, 2048] 51.9 µs 39.8 µs +30.53%
Simulation new_bp_prim_test_between[i64, 2048] 62.7 µs 45 µs +39.35%
Simulation new_bp_prim_test_between[i32, 32768] 168.6 µs 97.1 µs +73.67%
Simulation new_bp_prim_test_between[i64, 16384] 143.2 µs 72.6 µs +97.23%
Simulation new_bp_prim_test_between[i64, 32768] 236 µs 101.8 µs ×2.3
Simulation new_bp_prim_test_between[i32, 2048] 53.5 µs 40 µs +33.95%
Simulation take_10k_dispersed 284.4 µs 239.6 µs +18.67%
Simulation take_10k_first_chunk_only 270.4 µs 225.8 µs +19.75%
Simulation new_bp_prim_test_between[i32, 16384] 108.1 µs 68 µs +59.11%
Simulation patched_take_10k_contiguous_patches 258.3 µs 287.1 µs -10.02%
Simulation patched_take_10k_dispersed 315.5 µs 285.3 µs +10.59%
Simulation patched_take_10k_first_chunk_only 301.9 µs 271.8 µs +11.07%
Simulation new_alp_prim_test_between[f64, 16384] 155.1 µs 84.7 µs +83.11%
Simulation new_alp_prim_test_between[f32, 2048] 60.8 µs 50.3 µs +20.89%
Simulation new_alp_prim_test_between[f32, 32768] 168.8 µs 111.7 µs +51.11%
... ... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.


Comparing adamg/bitpack-compare (dbfb7c2) with develop (ac8c751)

Open in CodSpeed

Footnotes

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

@AdamGS AdamGS added the changelog/performance A performance improvement label Apr 3, 2026
@AdamGS AdamGS force-pushed the adamg/bitpack-compare branch from 74732ef to 8cddde0 Compare April 3, 2026 16:45
@AdamGS AdamGS added the action/benchmark-sql Trigger SQL benchmarks to run on this PR label Apr 3, 2026
@github-actions github-actions Bot removed the action/benchmark-sql Trigger SQL benchmarks to run on this PR label Apr 3, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 3, 2026

Polar Signals Profiling Results

Latest Run

Status Commit Job Attempt Link
🟢 Done 9177626 1 Explore Profiling Data
Previous Runs (9)
Status Commit Job Attempt Link
🟢 Done 083b4b4 1 Explore Profiling Data
🟢 Done 54608c5 2 Explore Profiling Data
🟢 Done dbe5a37 2 Explore Profiling Data
🟢 Done 54608c5 1 Explore Profiling Data
🟢 Done dbe5a37 1 Explore Profiling Data
🟢 Done db42e44 2 Explore Profiling Data
🟢 Done db42e44 1 Explore Profiling Data
🟢 Done 00d6bc4 1 Explore Profiling Data
🟢 Done abd15b8 1 Explore Profiling Data

Powered by Polar Signals Cloud

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 3, 2026

🚨🚨🚨❌❌❌ SQL BENCHMARK FAILED ❌❌❌🚨🚨🚨

Benchmark PolarSignals Profiling failed! Check the workflow run for details.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 3, 2026

🚨🚨🚨❌❌❌ SQL BENCHMARK FAILED ❌❌❌🚨🚨🚨

Benchmark TPC-H SF=1 on NVME failed! Check the workflow run for details.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 3, 2026

🚨🚨🚨❌❌❌ SQL BENCHMARK FAILED ❌❌❌🚨🚨🚨

Benchmark FineWeb NVMe failed! Check the workflow run for details.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 3, 2026

🚨🚨🚨❌❌❌ SQL BENCHMARK FAILED ❌❌❌🚨🚨🚨

Benchmark TPC-DS SF=1 on NVME failed! Check the workflow run for details.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 3, 2026

🚨🚨🚨❌❌❌ SQL BENCHMARK FAILED ❌❌❌🚨🚨🚨

Benchmark TPC-H SF=10 on NVME failed! Check the workflow run for details.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 3, 2026

🚨🚨🚨❌❌❌ SQL BENCHMARK FAILED ❌❌❌🚨🚨🚨

Benchmark Statistical and Population Genetics failed! Check the workflow run for details.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 3, 2026

🚨🚨🚨❌❌❌ SQL BENCHMARK FAILED ❌❌❌🚨🚨🚨

Benchmark Clickbench on NVME failed! Check the workflow run for details.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 3, 2026

🚨🚨🚨❌❌❌ SQL BENCHMARK FAILED ❌❌❌🚨🚨🚨

Benchmark FineWeb S3 failed! Check the workflow run for details.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 3, 2026

🚨🚨🚨❌❌❌ SQL BENCHMARK FAILED ❌❌❌🚨🚨🚨

Benchmark TPC-H SF=1 on S3 failed! Check the workflow run for details.

@AdamGS AdamGS added the action/benchmark-sql Trigger SQL benchmarks to run on this PR label Apr 3, 2026
@github-actions github-actions Bot removed the action/benchmark-sql Trigger SQL benchmarks to run on this PR label Apr 3, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 3, 2026

🚨🚨🚨❌❌❌ SQL BENCHMARK FAILED ❌❌❌🚨🚨🚨

Benchmark TPC-H SF=10 on S3 failed! Check the workflow run for details.

@AdamGS AdamGS added the action/benchmark-sql Trigger SQL benchmarks to run on this PR label Apr 3, 2026
@github-actions github-actions Bot removed the action/benchmark-sql Trigger SQL benchmarks to run on this PR label Apr 3, 2026
@AdamGS AdamGS force-pushed the adamg/bitpack-compare branch 2 times, most recently from a103738 to 4454bc6 Compare April 3, 2026 20:26
@AdamGS AdamGS changed the title Try to implement compare/between for bitpacked arrays Implement compare/between for bitpacked arrays - improve performance by up to 2X Apr 3, 2026
@AdamGS AdamGS requested review from gatesn and joseph-isaacs April 3, 2026 21:03
@AdamGS AdamGS force-pushed the adamg/bitpack-compare branch 2 times, most recently from 52289bf to dbe5a37 Compare April 3, 2026 21:29
@AdamGS AdamGS added the action/benchmark Trigger full benchmarks to run on this PR label Apr 3, 2026
@github-actions github-actions Bot removed the action/benchmark Trigger full benchmarks to run on this PR label Apr 3, 2026
@AdamGS AdamGS force-pushed the adamg/bitpack-compare branch from dbe5a37 to 33e6d30 Compare April 3, 2026 21:40
array.len(),
array.offset(),
|bit_width, packed_chunk, chunk_matches| unsafe {
U::unchecked_unpack_cmp(bit_width, packed_chunk, chunk_matches, compare, value);
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.

is the crux of this that we fuse unpacking with comparison op and avoid the second allocation/scan?

Copy link
Copy Markdown
Contributor

@joseph-isaacs joseph-isaacs Apr 9, 2026

Choose a reason for hiding this comment

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

ye, you save a lot on mem bandwidth, esp. for wider types

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.

TIL that we had fused cmp in fastlanes crate this whole time

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.

We lacked a good way to manage fused exection, I think now we have a bit of a better mechanism

@AdamGS
Copy link
Copy Markdown
Contributor Author

AdamGS commented Apr 22, 2026

@joseph-isaacs do we have an accepted way of measuring code size?

@AdamGS
Copy link
Copy Markdown
Contributor Author

AdamGS commented Apr 22, 2026

Main difference in build time is that vortex-fastlanes jumps from ~15 seconds to almost 50 (from 9th slowest crate to 2nd), command was cargo build -p vortex --release --timings --all-features.

While this isn't great for our local experience, I think it'll still parallelize fine with other heavy dependencies, and its pretty similar to what users will experience if they pull something like DF (which has multiple crates that takes 50-60 seconds to build)

@AdamGS AdamGS force-pushed the adamg/bitpack-compare branch 5 times, most recently from fc2ad24 to 083b4b4 Compare April 22, 2026 15:45
@AdamGS AdamGS added the action/benchmark Trigger full benchmarks to run on this PR label Apr 22, 2026
@github-actions github-actions Bot removed the action/benchmark Trigger full benchmarks to run on this PR label Apr 22, 2026
AdamGS added 12 commits April 24, 2026 09:59
Signed-off-by: Adam Gutglick <adam@spiraldb.com>
Signed-off-by: Adam Gutglick <adam@spiraldb.com>
Signed-off-by: Adam Gutglick <adam@spiraldb.com>
Signed-off-by: Adam Gutglick <adam@spiraldb.com>
Signed-off-by: Adam Gutglick <adam@spiraldb.com>
Signed-off-by: Adam Gutglick <adam@spiraldb.com>
Signed-off-by: Adam Gutglick <adam@spiraldb.com>
Signed-off-by: Adam Gutglick <adam@spiraldb.com>
Signed-off-by: Adam Gutglick <adam@spiraldb.com>
Signed-off-by: Adam Gutglick <adam@spiraldb.com>
Signed-off-by: Adam Gutglick <adam@spiraldb.com>
Signed-off-by: Adam Gutglick <adam@spiraldb.com>
@AdamGS AdamGS force-pushed the adamg/bitpack-compare branch from 083b4b4 to 695ce82 Compare April 24, 2026 08:59
Signed-off-by: Adam Gutglick <adam@spiraldb.com>
@AdamGS AdamGS added the action/benchmark-sql Trigger SQL benchmarks to run on this PR label Apr 24, 2026
@github-actions github-actions Bot removed the action/benchmark-sql Trigger SQL benchmarks to run on this PR label Apr 24, 2026
@joseph-isaacs
Copy link
Copy Markdown
Contributor

Diff size of and bin using this with and without the compare+bitpack

@joseph-isaacs joseph-isaacs added the action/benchmark Trigger full benchmarks to run on this PR label Apr 28, 2026
@github-actions github-actions Bot removed the action/benchmark Trigger full benchmarks to run on this PR label Apr 28, 2026
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.

4 participants