Repository navigation
Blocked BitPacked: encode blocked bitwidths - #10203
Merged
Merged
Conversation
mhk197
force-pushed
the
mk/bitpacked-variable-encode
branch
2 times, most recently
from
October 2, 2026 18:30
ad528cd to
662ffac
Compare
Merging this PR will not alter performance
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| 🆕 | WallTime | bitpack_blocked_compress_avx2 |
N/A | 7.7 µs | N/A |
| 🆕 | WallTime | bitpack_blocked_compress_avx512 |
N/A | 5.8 µs | N/A |
| 🆕 | WallTime | bitpack_blocked_compress_neon |
N/A | 11.4 µs | N/A |
Comparing mk/bitpacked-variable-encode (3471916) with develop (d97fb1c)
Footnotes
-
518 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
force-pushed
the
mk/bitpacked-variable-encode
branch
2 times, most recently
from
October 2, 2026 18:58
438829b to
75752c3
Compare
mhk197
force-pushed
the
mk/bitpacked-variable-encode
branch
from
October 2, 2026 19:12
75752c3 to
861873b
Compare
mhk197
marked this pull request as ready for review
October 2, 2026 19:14
mhk197
added this pull request to stack #10243
October 2, 2026 21:14
BitPacked: encode a bit width per blockBitPacked: encode blocked bitwidths
This was referenced Oct 2, 2026
mhk197
force-pushed
the
mk/bitpacked-variable-encode
branch
from
October 5, 2026 15:45
de28cfc to
fbf3501
Compare
Contributor
|
bitpack_to_best_bit_width and bitpack_to_best_bit_widths should be more distinct |
mhk197
force-pushed
the
mk/bitpacked-variable-encode
branch
from
October 5, 2026 16:22
fbf3501 to
f55497a
Compare
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>
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
mhk197
force-pushed
the
mk/bitpacked-variable-encode
branch
from
October 5, 2026 16:39
f55497a to
977cca1
Compare
Contributor
Author
|
@joseph-isaacs can do |
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
joseph-isaacs
approved these changes
Oct 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tracking Issue: #10167
Summary
Add per-block bit-packing, mirroring the single-width API:
bitpack_to_best_bit_width(array, ctx)bitpack_encode(array, bit_width, bit_width_freq, ctx)bitpack_blocked_to_best_bit_widths(array, ctx)bitpack_encode_blocked(array, bit_widths, num_exceptions, ctx)BitPackedData::encode_blocked(array, bit_widths, ctx)sits alongsideencode. Blocked output always stores its block offsets as a primitive array (BitWidths::Blocked). Choosing between uniform and blocked output is left to the caller.The single-width encoder is unchanged apart from sharing the non-negative check with the blocked encoder.
Design
Each block's width minimizes its packed size plus the cost of its exceptions, using the existing
best_bit_widthcost model on a per-block histogram. The zero padding of a partial last block and null values count as zero-width values, so every block is charged for its full128 * widthbytes. Each block's cost depends only on its own width, and blocked output always pays for its offsets, so choosing every block independently is optimal under this model.Block offsets use the narrowest unsigned type that holds the final offset.
Additionally, I made the choice to allow blocks that are not packed at all -- but only if there exists at least one block that IS packed. Otherwise, we could encounter a scenario where one block is unpacked and the rest are, and we reject on the basis of one block out of many. There are definitely some improvements that can be made in the future.
Scope
Nothing calls the new encoder yet.
fastlanes.bitpackedserialization requires a constant width, so wiring it into BtrBlocks waits for the variable-width wire format.Results
Measured locally on 64K
u32values with synthetic distributions, comparingbitpack_to_best_bit_widthswithbitpack_to_best_bit_width. Sizes are uncompressednbytes, from 262,144 raw bytes:On uniform and outlier data both encoders pack and patch identically. The 130 bytes are the materialized offsets (65
u16values).Median encode time, including choosing the widths (median of three local runs):