Repository navigation
Releases
Releases · M-Compressors/mopenzl
v0.2.10
Changes
- New opt-in
serdefeature (impliesframed):framing::serdestores
serdevalues and row streams in framed containers, column by column.
Importing the sealedSerdeCompressandSerdeDecompresstraits adds
compress_value,compress_rowsandrows_writertoFramedCompressor
anddecompress_value,decompress_rowsandrows_readerto
FramedDecompressor. Every site of a value (a struct field, a sequence's
elements, an enum's variant index, anOption's flag) becomes one typed
input: numbers numeric, strings and bytes string,u128/i12816-byte
struct; lengths and variant indices are narrowed per block. Rows are cut
into blocks of aboutBlockSizeraw bytes (1 MiB by default), one
self-contained resource each, with a layout descriptor in metadataSD.
Each resource's frame equals the reference'scompress_genericframe of
the same columns. The descriptor stores the block's schema (field and
variant names, the kind of every column), so the format describes itself:
fields are matched by name, a place may change shape between visits (a
one-byte state column records which shape, or that a field was skipped),
anddeserialize_anyreports the stored value.skip_serializing_if,
#[serde(skip)], added and removed fields, untagged, internally and
adjacently tagged enums,flattenandserde_json::Valueround-trip, and
numbers convert as serde's visitors allow (widening yes, lossy or
float/integer reinterpretation no). Maps whose keys are names (strings,
unit variants, newtypes of them) are stored as records: each distinct key
gets its own columns, and a key column keeps entry order and repeats; a
map names at most 256 keys per block and stores the rest as values. On
100k JSON log lines asserde_json::Valuethe container is 15.12x smaller
than the JSON text (8.76x for the text through serial OpenZL; 9.92x with
keys stored as values). Onbenches/framed_serde.rsthe
container is 9.51x smaller than 100k structured log rows in a row-major
layout (5.69x for that layout through serial OpenZL) and 11.50x for 200k
numeric samples (3.96x). Rows decode at 350-650 MiB/s of row-major size;
the columns themselves decode at C speed and rebuilding rows dominates. framing::serde::columns, an attribute macro from the new
mopenzl-macroscrate (pulled in byserde), placed above the serde
derives.#[column(id = N)]stores a named field by number instead of by
name, like protobuf: the block schema drops the name, a renamed field keeps
reading earlier rows, and the field also accepts the key"#N", so
numbered structs read through untagged and internally tagged enums,
flattenandserde_json::Value.#[column(codec = "graph")]compresses
the columns of the field's values with the compressor's graph of that name
(a standard graph, or one registered withGraphParams::with_name); a
block with such columns is compressed with a router graph that sends each
marked column to its graph, converting it to serial bytes for serial-only
graphs, and the other columns together to the compressor's start graph.
Blocks without codecs are unchanged, the decoder needs no configuration,
and the C library decodes the routed frames. Other formats see marked
types unchanged. A codec that cannot be used is the new
SerdeError::Codec. Field names are now limited to 65534 bytes.#[column]keeps a field's ownwithorserialize_within generic types:
the expansion declares a wrapper next to the item over the parameters the
field's type mentions and the bounds on them.- The workspace shares one version:
[workspace.package]holds the version,
edition, minimum Rust, license and links thatmopenzl,mopenzl-macros
andopenzl-ffiinherit (openzl-ffimoves from 0.1.0 to the crate
version), and[workspace.dependencies]pinsmopenzl-macrosto the same
exact version. The release workflow publishes both crates with
cargo publish --workspace. - README, crate documentation and the book introduce the
serdefeature as a
compressed serialization format for any Rust type, with examples and the
measured ratios;serdeis a crate keyword.
v0.2.9
Changes
Decompressor::decompress_typed_intodecodes a typed or multi-output frame
into a caller'sVec<TypedOutput>, refilling the outputs of an earlier call
instead of allocating new ones. An output still takes its stream's buffer
without a copy; the stream now gets the output's former buffer in exchange,
so for frames of a steady shape the same buffers alternate between caller
and decoder. Where the allocator returns large blocks to the system
(MALLOC_MMAP_THRESHOLD_=1048576),decompress-typed/seriesdecodes 27 MiB
in 7.9 ms instead of 11.1 ms and 4.5 MiB in 0.91 ms instead of 1.43 ms; with
glibc's default recycling it is level withdecompress_typedon 27 MiB
(8.27 ms against 8.37 ms) and 2-8% slower on 4.5 MiB, where the
alternating buffer is less cache-hot than the block glibc just freed.
decompress_typedis unchanged. The decoder keeps the outputs' former
buffers between calls, so the caller and the decoder together hold about
twice the outputs' size, and underRetentionPolicy::Boundedthe spares
count toward the bound.hotpath0.33.1 for the profiling features, the Criterion benches and
benchmarks/comparison(which was still on 0.31 and so locked a second
hotpathbeside the library's). 0.33.1 is the floor:hotpath-macros
0.33.1 calls a builder method thathotpath0.33.0 lacks.- The fuzz targets build with
afl0.19 and CI installscargo-afl0.19.0
(AFL++ 5.03c). Dependabot now leavesafl's minor updates in
/fuzz/libfuzzerto the same by-hand bump as/fuzz/afl. Cargo.locktakescookie0.18.3 (GHSA-8wcq-xq25-7fhm, private cookie
nonces repeating afterfork). It arrives only throughhotpath's
ureqcookie store, which uses no private cookies, so the library was
not exposed; the bump clears the Dependabot alert.
Fixes
- The
fse_ncountcodec reads count headers exactly as the reference's
FSE_readNCountdoes near the end of the buffer: its 4-byte window stops
at the last word and the bit offset wraps, so a header that runs off its
end re-reads bits of that word instead of failing. Such headers decoded in
C but were rejected here asCodecStream. ClusterFuzzLite found it
(decompress, run 46262875131).openzl-ffigains
entropy::fse_read_ncount(shim/entropy.c) for the differential test.
v0.2.8
Changes
- Reference updated to zstd 1.6.0.
openzl-ffi's zstd submodule moves
from 1.5.7 (the version OpenZL v0.3.0 vendors) to 1.6.0, andmzstdto
0.2.17, whose encoder is byte-identical to 1.6.0. Frames change where
1.6.0's do (long distance matching, btopt-and-above dictionaries, block
splitting), and the zstd codec rejects matches into a Zstandard-format
dictionary's header and tables, as 1.6.0'sZSTD_DDictdoes.
Fixes
- The zstd codec decodes frames declaring a window of exponent 31 with any
mantissa, up to 3.75 GiB, as the reference's one-shot
ZSTD_decompress_usingDDictdoes (mzstd's
DecodeLimits::with_unbounded_window); 0.2.7 stopped at 2 GiB.
v0.2.7
- The zstd codec decodes frames whose header declares a window above
128 MiB (up to log 31), as the reference's one-shot
ZSTD_decompress_usingDDictdoes; mzstd's default window limit is the
streaming one, which the reference does not apply here. ClusterFuzzLite
found it (decompress, run 45623880731).
v0.2.6
Features
framing::FramedIndex,FramedDecompressor::framed_indexand
FramedDecompressor::read_indexed_resourcegive index-based random access
to a framed container without a reader that borrows the decoder. The index
owns the validated directory and the container's start position, so a
caller can keep the decoder, the source and the index in one struct. It
works with any decoder and any source holding the same bytes at the same
positions; each read seeks itself and applies the reading decoder's limits.
framed_seek_readerandFramedSeekReaderare now built on these calls,
with unchanged signatures and behaviour.
Fixes
Decompressor::decompress_typedandDecompressor::frame_infoaccept a
one-output frame whose inputs token sets the type bits of an absent second
output, asZL_FrameInfoand the reference's typed decoder do. Only the
byte-oriented paths still reject it, as the reference's
ZL_getDecompressedSizedoes. ClusterFuzzLite found it
(decompress_typed, run 44733372399).
v0.2.5
Changes
- Update hotpath to 0.32
Fixes
- The
bitunpackdecoder now packs numbers wider than their field the way
the reference's portableZS_bitpackEncodekernels do, rather than masking
them. Only damaged frames hold such numbers. Excess bits of 8- and 16-bit
numbers spill into the next field, up to 64 one-bit fields of 32-bit
numbers are summed with carries, other 32-bit fields go through the
reference's 64-bit accumulator, and byte-aligned fields and 64-bit numbers
stay masked. The CI fuzz run found it (decompress, run 44731741289). openzl-ffiexposesenc_backends::bitpack_encode, the C
ZS_bitpackEncodekernel, as a test oracle. It compiles OpenZL's
common_bitpack_kernel.cthroughshim/bitpack_kernel.cwith__BMI2__
undefined, so the oracle runs the portable kernels on every host. Built
with AVX2 and BMI2 (as cargo-afl's-Ctarget-cpu=nativedoes on CI), the
reference packs out-of-range numbers differently, and thedecompress
regression replay failed on the x86 runner.- The decoder now accepts three kinds of frame that the reference decodes
and it rejected. ClusterFuzzLite found them (decompress,
decompress_typed, run 43709071038).Decompressor::decompress_typeddecodes a frame without chunks to empty
outputs when every declared size is 0, as
ZL_DCtx_decompressMultiTBufferdoes. It still reports
InvalidData { EmptyFrame }when the frame ends less than five bytes
after its inputs token. The byte-oriented decoders still reject every
frame without chunks, asZL_DCtx_decompressdoes.- A Zstandard stream may hold several magicless frames, which are decoded
one after another asZSTD_decompress_usingDDictdoes. Bytes after the
first frame used to be rejected asCodecStream. convert_serial_to_structandsplitnregenerating a chunk output
concatenate their serial and struct inputs without checking them against
the codec's signature, as the reference's
ZL_AppendToOutputOptimizationdoes. Such a frame used to be rejected
asGraph.
- The
decompress_typedfuzz oracle accepts the reference's
ZL_Type_unassignedfor an empty struct or numeric output that no chunk
wrote. - The C oracle (
openzl-ffi) now compilesallocation.cwith its 100 MiB
allocation cap and bounds single and cumulative allocations during
mzl_decompressandmzl_decode_typedthroughZS2_malloc_should_fail, so
damagedpivco_huffmanandsparse_numframes that claim multi-gigabyte
streams fail inZL_mallocinstead of exhausting memory under
ClusterFuzzLite (decompress,decompress_typed, run 44520833376).
Decompressor::decompress_typedalso counts four bytes per declared string
towardDecodeLimits::max_output_bytes.
v0.2.4
Fixes
GraphBuilder::clusteringandclustering_with_codecsno longer panic in
debug builds, or wrap in release builds, on aClusteringConfigdecoded
from CBOR whose successor or codec index isusize::MAX. The index is now
rejected like any other out-of-range codec index. Found by ClusterFuzzLite
(graph_configs).- ClusterFuzzLite now builds the C oracle without the image's
-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION. With that define, the
vendored OpenZL skips checksums and caps LZ match lengths at 1024, which
produced falsedecompress,decompress_typedandnode_roundtrip
findings.openzl-ffi's build script now refuses to compile with the
define.
Documentation
- Reorganize the documentation website and the README for readers, matching
the mbrotli and mzstd books. The sidebar has six parts in reading order
(Start here, Graphs and codecs, Guides, Performance and correctness, How it
works, Contributing) and folds nested chapters: the per-graph benchmark
pages and the architecture specifications open under their parent.
architecture/README.mdgroups its specifications into sections with
reading paths and shorter scopes, and each section gets a generated landing
page. The catch-all user guide is split intodocs/configuration.md,
docs/memory.md,docs/decompression.mdanddocs/streaming.md;
docs/README.mdbecomes the API chooser, and output compatibility moves
intodocs/correctness.md. The landing page leads with a round trip, a
typed-input example and a graph chooser. The theme has its own light and
dark palette and a dialog that shows a Mermaid diagram at its natural size.
The README drops from 528 to 387 lines: quick start first, then typed data
and custom graphs, one API table, and links into the site. Its memory-reuse
andRead/Writeexamples move to the memory and streaming guides; its
dictionary example is dropped in favour of the dictionary guide.
tests/docs_examples.rsis regenerated for the new pages (31 examples
before, 30 after). The book build now also checks every README link into the
published site. Documentation only; the crate is unchanged.
v0.2.3
Fixes
- Create the AFL smoke findings parent directory on clean CI checkouts before
AFL creates its per-target output directories. - Classify the opt-in
framedfeature in the CI consumer matrix and probe its
metadata, direction-specific APIs and std transport adapters with framing
enabled and disabled. Configure the AFL smoke runner before fuzzing so the
Ubuntu core dump handler does not abort startup; archive findings so AFL's
colon-containing filenames can be uploaded as artifacts.
Documentation
- Migrate the complete user guide, architecture, benchmark charts and CSVs to
mdBook on GitHub Pages, using the mbrotli book's chapter structure and build
pipeline with mopenzl API recipes. Lead navigation with graphs, codecs and
typed inputs; add getting-started, Sans I/O, std I/O, resource framing,
parallel/Rayon, compatibility and publishing guides. Validate source coverage,
HTML links/anchors and all user-guide Rust programs; update the package homepage.
Added
- Opt-in
framedfeature andframing::{FramedCompressor, FramedDecompressor}:
indexed containers of independent OpenZL frames, a separate graph per resource,
serial/typed/multiple inputs, validated resource metadata, bounded native
sessions, resource-oriented std reader/writer adapters with transport retries,
and whole-resource random access through a checked seek directory. Inner frames
keep ordinary OpenZL compatibility; the outer container is mopenzl-specific.
Includes C interoperability tests, AFL/libFuzzer targets and Criterion cases.
v0.2.2
Added
compressor::parallel::ParallelCompressorwith the mbrotli caller-scheduled
batch, task, source, staging, retention, streaming and I/O interfaces. Parallel
segments form one OpenZL-compatible frame; reference byte identity is not a
contract. Streaming retains compressed chunks until finish to announce the
total input size. Includes C interoperability tests, AFL/libFuzzer coverage
and Criterion comparisons with the C serial segmenter. List the parallel
entry points in the crate documentation and README API chooser tables.ParallelCompressor::builder(...).with_graph(...)and
ParallelCompressorBuilder: serial-style graph/codec selection for every
worker, source, fallback and streaming adapter. Preserve dictionary metadata
during one-frame assembly and selected graphs across encoder reconfiguration;
propagate graph/header failures with typed source errors.
Fixes
- Reduce the Miri suite to focused SIMD-kernel and uninitialized-output tests
to avoid CI timeouts. Keep exhaustive scalar codec tests in the native and
AddressSanitizer suites, and validate exact Miri test names before running.
Run three PivCo tests using unsupported Neon shifts in x86-64 Miri and
ARM64 AddressSanitizer instead of ARM64 Miri. - Make parallel streaming examples validate round trips without codec features,
and require size reduction only when Zstandard is enabled. Select enabled
standard graphs at compile time in the parallel integration test so every
CI feature configuration passes Clippy.
v0.2.1
Added
- Add hotpath CI profiles for the compressor and Criterion compression and
decompression cases, merging native timing and allocations with Callgrind
instruction counts. Pushes upload to hotpath-cloud using OIDC; pull requests
publish artifacts for a separate relay workflow. Addhotpath-callgrind
andhotpath-cloudfeatures and a repeatableprofile_compressorexample. custom-codec(enabled by default):CustomCodec, typed callback inputs,
validated signatures and encoder/decoder contexts; graph-node registration
and custom decoder registration by wire ID, including private headers,
variable ports, parameterization and streaming. Unregistered custom IDs
continue to returnUnsupported. The user guide
documents registration, supported stream types and feature selection.
Performance work across the codec families, measured on the whole Silesia
corpus against OpenZL v0.3.0 C (-O3). Frames are unchanged: every one of the
123 benchmarked graph/file pairs is byte-identical to C. Figures are medians of
per-file C time / Rust time, before → after
(results).
Performance
- PivCo-Huffman:
- Table-driven 16-byte merge and partition kernels, plus AVX-512
expand/compress kernels. - SIMD flat leaves and packing, allocation-free trees.
- Compress 0.09× → 1.05×, decompress 0.05× → 1.03×.
lzdecoding, which uses it, went from 0.44× to 1.46×.
- Table-driven 16-byte merge and partition kernels, plus AVX-512
- Huffman and FSE:
- Huffman decodes through a pair table with sentinel refills, four lanes and
several symbols per refill. FSE decodes four symbols per refill. - The Huffman encoder uses a top-aligned two-container writer like
HUF_addBits. FSE and the Huffman weights use a 64-bit word writer. - Fixed-size tables and 8-byte histogram loads.
- The four Huffman lanes decode in lockstep over output quarters with a
stack-resident pair table filled in runs; 16-bit Huffman decodes its four
blocks in lockstep. - FSE decodes through a shift-only loop when no cell reads zero bits, builds
tables with the reference's fast spread, and encodes with states in
locals into a fixed-size word buffer. - The Huffman encoder looks up scale-8 entry tables and adds codes in groups.
- The Huffman lane loop looks up all four lanes before storing, writes
through shrinking per-lane window slices and indexes a pair table of
2^logcells by the top bits; it executes fewer instructions than C. - Huffman: compress 0.40× → 0.94×, decompress 0.20× → 0.78×. FSE: 0.44× →
0.95×, 0.29× → 0.88×.
- Huffman decodes through a pair table with sentinel refills, four lanes and
- LZ4:
- Short- and long-sequence fast paths with chunked copies in the decoder.
- A const-generic HC chain walk with hoisted candidate reads and 8-byte
count/count_back. - Fixed-size HC tables, an inlined HC match search, and single-compare
bounds on its reads. - The decoder's fast loop checks one 288-byte input and 640-byte output
window per sequence and keeps long-match copies out of line. Past the
first 64 KiB of output, sequences run in one fixed-size window where
every offset is valid, with C's 8+8+2-byte short-match copy. - Compress 0.78× → 0.95×, decompress 0.31× → 0.92×.
lzandfield_lz:- 128-byte row-table rows with a
fearless_simdtag compare and fused
candidate scoring. - Parsers monomorphized per SIMD level and field width.
- Chunked match copies in the decoders, and table-driven quantize.
- The field_lz parse warms the rows it will probe with stores a few
positions ahead, keeps rows on two cache lines, and fixes the hash length
at compile time. - The field_lz decoder runs four tokens per group, resolves their repeat
offsets from a 256-entry table (C's AVX2 shuffle, in scalar form) and
copies short runs as fixed 16-byte blocks; it is at C's instruction count. lzcompress 0.49× → 0.83×, decompress 0.44× → 1.46×.field_lzon 4-byte records: compress 0.60× → 0.83×, decompress 0.32× →
0.76×.
- 128-byte row-table rows with a
- bitpack, flatpack, transpose, tokenize, partition:
- SIMD bit counting and grouped packing in bitpack.
- 8-per-word packing and table-driven decode in flatpack.
- A SIMD byte transpose (
shared::byte_transpose). - Hashed tokenize and specialized gathers.
- A 64-bit partition bit reader.
- bitpack compress 0.08× → 1.77×. flatpack 0.73× → 1.47× (compress) and
1.43× → 1.49× (decompress).
- Engine:
- The decoder hands the last regenerated stream to an empty
Vec
destination orTypedOutputinstead of copying it. - A single typed output is checksummed in place.
compressandcompress_inputsstart their frameVecat the compression
bound instead of growing it.
- The decoder hands the last regenerated stream to an empty
- Numeric graphs (16/32-bit numbers through the numeric selector): compress
0.48–0.62× → 0.83–0.94×, decompress 0.27–0.37× → 0.71–0.83×.
Tooling
benchmarks/comparison: a harness that runs every standard graph on Silesia
against C. It hasverify,runandprofile(callgrind/perf/hotpath)
commands.report.pyrenders charts and tables intodocs/benchmarks/.openzl-ffireadsOPENZL_FFI_OPT_LEVELto build the C library at-O3
for benchmarks (tests keep-O2).- The SIMD level is plumbed to every codec:
NodeCx::simdfor encoders and
State::simdfor decoders.
Fixes
lz_common::count's padded fallback path is bounds-safe for runs that end
past the data.