Expand description
wasm-bitpack is a SIMD-accelerated integer bit-packing and unpacking library with a
hand-written WebAssembly SIMD128 decode fast path.
Every popular Rust integer-compression crate gets its speed from x86 AVX2/SSE
intrinsics and silently falls back to scalar code when compiled to wasm32. This crate
implements the missing wasm32 + simd128 decode fast path instead.
See the project README for the full pitch, benchmark methodology, and usage examples.
Structs§
- Scalar
- Portable, safe-Rust reference implementation of
BitPacker. - Wasm128
- SIMD128-accelerated
BitPackerimplementation.
Traits§
- BitPacker
- A fixed-block-size integer bit-packing codec.
Functions§
- best_
available - Returns the fastest
BitPackerimplementation available for the current compile target:Wasm128when compiled forwasm32withsimd128enabled,Scalarotherwise. - compress_
sorted - Delta-encodes a non-decreasing (duplicates allowed) sequence and packs it into
compressed, returning the number of bytes written. - compress_
strictly_ sorted - Delta-encodes a strictly increasing sequence and packs it into
compressed, returning the number of bytes written. - decompress_
sorted - Unpacks
compressed(as produced bycompress_sorted) intodecompressed, returning the number of bytes read. - decompress_
strictly_ sorted - Unpacks
compressed(as produced bycompress_strictly_sorted) intodecompressed, returning the number of bytes read. - num_
bits_ sorted - Returns the minimum number of bits needed to delta-encode
decompressedforcompress_sorted— the widest consecutive difference in a non-decreasing sequence.decompressed[0]itself is excluded (it’s stored as a raw header, not delta-encoded — see the module docs), so this reflects genuine step sizes, notdecompressed[0]’s own magnitude. - num_
bits_ strictly_ sorted - Returns the minimum number of bits needed to delta-encode
decompressedforcompress_strictly_sorted— the widestconsecutive difference - 1in a strictly increasing sequence.decompressed[0]itself is excluded, same asnum_bits_sorted. - pack
- Packs an arbitrary-length slice of
u32values intocompressedatnum_bitsbits per value, returning the number of bytes written. - unpack
- Unpacks an arbitrary-length,
num_bits-packed byte buffer intodecompressed, returning the number of bytes read.