μpack
A highly optimised bitpacking SIMD library with zero dependencies that aims to provide more flexibility when compressing integers.
Bitpacking blocks of integers with SIMD is not a new idea, with the simdcomp library by Daniel Lemire being one of the most well known implementations. However, this library has one novel difference; unlike simdcomp and other bitpacking algorithms, μpack supports variable size output blocks.
This means if you have a block that is not some fixed sized (in μpack's case, 128 elements.) You can safely truncate the compressed output without data loss.
The reason why this is possible is because blocks that are smaller than 128 elements are packed in a way that maintains their original ordering.
Features
- Optimised AVX512, AVX2 and NEON implementations of the compression routines.
- Optimised scalar fallback which can optimise well for SSE3, LoongArch, etc...
- Variable size output blocks offering better compression ratios than StreamVByte and other algorithms that are typically used when there is not enough data to compress a full block.
- Zero dependencies, Zero allocations.
- Supports
u32andu16integers,u64is possible, but is not currently on my radar for now. - Delta and Delta-1 encoding variants available for sorted sequences offering better compression ratios.
Example
const EXPECTED_BITLENGTH: usize = 3;
Benchmarks
You can run the benchmarks via
just bench
By default, this runs the uint32 benchmarks, you can select the uint16 benchmarks via:
just bench --kind uint16
Small Summary (uint32)
Compression


Decompression

