Skip to content

Blocked BitPacked: decode blocked bitwidths - #10202

Open
mhk197 wants to merge 11 commits into
developfrom
mk/bitpacked-variable-decode
Open

mhk197 wants to merge 11 commits into
developfrom
mk/bitpacked-variable-decode

Conversation

@mhk197

@mhk197 mhk197 commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Tracking Issue: #10167

Summary

Adds support for decoding BitPacked arrays with blocked bitwidths.

Now each public function that decodes bitpacked arrays with global bitwidths has a version for blocked bitwidths.

Global width Blocked
unpack_array(array, ctx) unpack_array_blocked(array, offsets, ctx)
unpack_primitive_array unpack_primitive_array_blocked
unpack_into_primitive_builder unpack_into_primitive_builder_blocked
unpack_single(array, index) unpack_single_blocked(array, offsets, index, ctx)

Callers choose between them by matching on bit_widths().

There is no blocked unpack_map_into_builder: its only caller, the widening CastKernel, declines blocked arrays, so the mapped path would only run in tests.

Design

#10004 only checks block boundary values in debug builds, so the decoder checks them itself:

  • Bulk decode casts the offsets child to u64 and executes it once, checks that it holds one boundary per block plus a trailing one, and validates every boundary before writing to the builder. A single offset type keeps one copy of the block loop per value type, for 8 bytes per 1024 values. Each block must be a whole number of 128-byte rows, no wider than the array's type, and the boundaries must span the packed buffer.
  • scalar_at reads only the selected block's boundaries, directly for host primitive offsets and through execute_scalar otherwise, and validates just that block.

Both use block_range in bitpacking/array/mod.rs, which validate_primitive_offsets now also uses. Boundaries are relative to the first one, which may be nonzero.

Full blocks unpack straight into the output, like the global decoder's full chunks. A partial first or last block unpacks into one 1024-value scratch block.

@mhk197 mhk197 added the changelog/skip Do not list PR in the changelog label Oct 2, 2026
@mhk197 mhk197 changed the title Blocked BitPacked: decode variable bit widths Blocked BitPacked: decode blocked bit widths Oct 2, 2026
@mhk197
mhk197 force-pushed the mk/bitpacked-variable-decode branch from 6ada699 to e780ee8 Compare October 2, 2026 19:26
@codspeed

codspeed Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 11.59%

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

⚠️ 2 benchmarks measured no execution time

Nothing ran under measurement, usually because the compiler removed the code under test. These results are not comparable, so they count as unchanged.

Preventing compiler optimizations

❌ 1 regressed benchmark
✅ 2182 untouched benchmarks
🆕 6 new benchmarks
⏩ 409 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ WallTime bitpack_blocked_compress_avx2 6.7 µs 7.6 µs -11.59%
🆕 WallTime bitpack_blocked_decompress_avx512[u32] N/A 9.4 µs N/A
🆕 WallTime bitpack_blocked_decompress_avx512[u64] N/A 18.9 µs N/A
🆕 WallTime bitpack_blocked_decompress_avx2[u32] N/A 10.8 µs N/A
🆕 WallTime bitpack_blocked_decompress_avx2[u64] N/A 21.2 µs N/A
🆕 WallTime bitpack_blocked_decompress_neon[u32] N/A 13.8 µs N/A
🆕 WallTime bitpack_blocked_decompress_neon[u64] N/A 29.3 µs N/A
⚠️ Simulation bench_compare_primitive[(10000, 2)] < 1 ns < 1 ns N/A
⚠️ Simulation bench_compare_sliced_dict_primitive[(3333, 10000)] < 1 ns < 1 ns 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 mk/bitpacked-variable-decode (75fe6ef) with develop (c901cf7)

Open in CodSpeed

Footnotes

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

@mhk197
mhk197 force-pushed the mk/bitpacked-variable-decode branch 3 times, most recently from 957cefe to 67da367 Compare October 2, 2026 21:08
@mhk197
mhk197 changed the base branch from mk/bitpacked-stack-03-width-child to mk/bitpacked-variable-encode October 2, 2026 21:08
@mhk197
mhk197 added this pull request to stack #10243 October 2, 2026 21:14
@mhk197
mhk197 marked this pull request as ready for review October 2, 2026 21:35
@mhk197 mhk197 changed the title Blocked BitPacked: decode blocked bit widths Blocked BitPacked: decode blocked bitwidths Oct 2, 2026
@mhk197
mhk197 force-pushed the mk/bitpacked-variable-decode branch from b6f53eb to c70f089 Compare October 5, 2026 15:50
@mhk197
mhk197 force-pushed the mk/bitpacked-variable-decode branch 2 times, most recently from 760be2a to 656dea8 Compare October 5, 2026 16:39
Base automatically changed from mk/bitpacked-variable-encode to develop October 6, 2026 14:16
mhk197 added 7 commits October 6, 2026 15:16
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
@joseph-isaacs
joseph-isaacs force-pushed the mk/bitpacked-variable-decode branch from 656dea8 to 0fdbb09 Compare October 6, 2026 14:16
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
@mhk197
mhk197 requested a review from joseph-isaacs October 9, 2026 15:04
mhk197 added 3 commits October 9, 2026 11:09
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
output: &mut [MaybeUninit<T>],
) {
let packed = array.packed_slice::<T::Physical>();
let mut scratch = [const { MaybeUninit::<T>::uninit() }; FL_CHUNK_SIZE];

@joseph-isaacs joseph-isaacs Oct 9, 2026 •

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.

Do we do the same in unblocked?

@mhk197 mhk197 Oct 9, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes I believe so

Comment on lines +113 to +118

decode_blocks(array, &offsets, uninit_slice);

if let Some(patches) = array.patches() {
apply_patches_to_uninit_range(&mut uninit_range, &patches, ctx, |v: T| v)?;
}

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.

you want overlap patches and blocks

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is what global does as well, can have as a followup pr

}

/// Decode the blocks between validated `offsets` into `output`.
fn decode_blocks<T: BitPackedUnpack>(

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.

how is the offset metadata considered here (if you are sliced say 9 values into a block)

@mhk197 mhk197 Oct 9, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

for first block we unpack into scratch buffer but only copy scratch[offset..]

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/skip Do not list PR in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants