Repository navigation
Optimise bitpacked filtering and take for valid runs - #10281
Conversation
0e06ee5 to
fd431ca
Compare
Merging this PR will regress 1 benchmark
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | WallTime | bitpack_blocked_compress_avx2 |
6.8 µs | 7.6 µs | -10.78% |
| ⚡ | WallTime | threshold_neon[8] |
2.8 µs | 1.5 µs | +92.76% |
| ⚡ | WallTime | threshold_neon[64] |
4.3 µs | 2.7 µs | +61% |
| ⚡ | WallTime | filter_neon[64] |
2.7 µs | 1.8 µs | +52.33% |
| ⚡ | WallTime | threshold_avx2[8] |
1.9 µs | 1.4 µs | +38.72% |
| ⚡ | WallTime | threshold_avx512[8] |
2 µs | 1.5 µs | +38.4% |
| ⚡ | WallTime | filter_avx512[80] |
2.3 µs | 1.7 µs | +37.14% |
| ⚡ | WallTime | threshold_avx2[80] |
3.3 µs | 2.6 µs | +28.15% |
| ⚡ | WallTime | filter_avx2[64] |
2.1 µs | 1.6 µs | +25.69% |
| ⚡ | WallTime | filter_avx512[64] |
2.1 µs | 1.7 µs | +23.27% |
| ⚡ | WallTime | filter_avx2[80] |
2.2 µs | 1.8 µs | +22.12% |
| ⚡ | WallTime | threshold_avx512[64] |
3 µs | 2.5 µs | +21.35% |
| ⚡ | WallTime | threshold_avx2[64] |
3 µs | 2.5 µs | +21.33% |
| ⚡ | WallTime | threshold_neon[80] |
4.7 µs | 3.9 µs | +19.02% |
| ⚡ |
Simulation | random_i128[0.01] |
7.6 µs | 6.4 µs | +18.66% |
| ⚡ | WallTime | threshold_avx512[80] |
3.3 µs | 2.8 µs | +16.81% |
| ⚡ | WallTime | filter_avx2[8] |
1,053 ns | 904 ns | +16.48% |
| ⚡ | WallTime | filter_neon[80] |
2.9 µs | 2.5 µs | +14.3% |
| ⚡ | WallTime | starts_with_avx512[8, VarBin] |
46.3 µs | 40.5 µs | +14.21% |
| ⚡ | Simulation | random_i128[0.8] |
175.3 µs | 154.3 µs | +13.62% |
| ... | ... | ... | ... | ... | ... |
ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing rk/bitpacked-filter (066e637) with develop (505fcfa)
|
Do you have any numbers here? |
3b7d6ec to
cc8e9cb
Compare
04aca9b to
89220a8
Compare
…rializing indices BitPacked's filter kernel only handled very sparse masks (below 3-9% density), and for those it materialized the mask's `usize` indices first; any denser mask unpacked the whole array before filtering. The kernel now walks the selection one 1024-value FastLanes chunk at a time: from the mask's cached slices when it has them (as FixedSizeList element masks do) and otherwise straight from the bitmap. Empty chunks are skipped, fully selected chunks unpack directly into the output, chunks with few selected values use `unchecked_unpack_indices` on a small stack array, and the rest unpack into an L1-resident scratch chunk that is compacted with run copies, a branch-free loop or a trailing-zeros walk per mask word. Dense masks with scattered values still decline the kernel, so the vectorized canonical filter handles them. Adds a `bitpacking_filter` benchmark covering primitive i32 and FSL<i32> elements bit-packed to 16 bits. Each iteration builds a fresh mask so cached indices are not reused across iterations. Signed-off-by: Claude <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GEPn56FBLoa8Yq6jexAwWL
…uses SIMD The chunked BitPacked filter declined only above a fixed 0.2 density, which only matches the canonical filter's SIMD compress crossover for 4-byte values. For u8 and u16 the canonical filter compacts with AVX-512/AVX2/NEON at much lower densities, so the chunked kernel was 2-6x slower there. Expose `uses_simd_compress::<T>(mask)` from vortex-array and decline whenever the canonical filter would compact with SIMD, except for very sparse masks (<= 1%) and masks with long cached runs. Also drop the branch-free word compaction, which ran the full word up to the last selected value and was 20-25% slower than the trailing-zeros walk at the densities where it was used. Signed-off-by: Claude <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AazYKY45Y5yuV5NCYwqbNf
Signed-off-by: Will Manning <will@willmanning.io> Signed-off-by: "Robert Kruszewski" <github@robertk.io>
Use FL_CHUNK_SIZE for the FastLanes chunk length. Drop the max_sparse and indices fields from ChunkedFilter: compute the sparse threshold from the value width and keep the index scratch on the stack of each walk. Signed-off-by: Robert Kruszewski <github@robertk.io> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
filter_chunked is public, but its docs linked to the private chunked module for the chunk strategies. Move the strategy table into the filter_chunked docs and remove the links to private items. Signed-off-by: Robert Kruszewski <github@robertk.io> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
filter_buffer uses the cached indices of a mask when the density is at most 0.5, but filter_chunked always walked the whole bitmap. For sparse masks with cached indices, such as masks from Mask::from_indices, the walk over every empty chunk cost more than the decode itself. Add the cached indices step to filter_chunked, between the cached slices and the bitmap, with the same density rule as filter_buffer. Signed-off-by: Robert Kruszewski <github@robertk.io> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
89220a8 to
066e637
Compare
There was a problem hiding this comment.
move to vortex-buffer (can be a follow up).
joseph-isaacs
left a comment
There was a problem hiding this comment.
Can we this filter magic for fixed width compute
Previous code assumed indices but these are almost never cached. Instead we handle the slices (which can be produced by lists) and bit buffers which are the default