yolowzstd is a Zstandard (RFC 8878) encoder and decoder written in 100% safe Rust — #![forbid(unsafe_code)], zero runtime dependencies. Version 0.1.3, released today, reworks the encoder at every level band and the entropy layer underneath it. The mid levels get a new matcher, the high levels get an optimal parser, the fast levels learn to skip what won't compress, and decoding speeds up by up to 29.5%.
The problem: the middle levels were the worst of both worlds
Take a concrete workload: a Rust archival pipeline. Data lands all day — logs, JSON dumps, fetched documents — and gets compressed for storage, then decompressed every time anything reads it back. You chose a pure-Rust zstd because the codebase forbids unsafe and you don't want a C dependency in the build.
Before this release, the level dial had a dead zone. Level 9, the natural "balance" setting, encoded Silesia at 17.1 MB/s — too slow to use — while delivering a ratio (3.48×) that didn't justify the wait. High levels were slower still. And decode, your read path, topped out around 650 MB/s at level 19 settings. 0.1.3 is organized as one fix per band.
Levels 5–11: a SWAR row matcher
The old matcher walked linked hash chains. The new one is a tag-filtered row hash in the SwissTable/Zstd RowHash lineage, built on SWAR — SIMD Within A Register: comparing 8 bytes at once using integer arithmetic on a single 64-bit register, no SIMD intrinsics, no unsafe. Candidate rows are filtered by exact tags before any real comparison, a 128 KiB table tracks near offsets with zero false positives, and lazy matching looks ahead with rate-distortion pricing (a match is only taken if its bit savings beat its bit cost).
Result at level 9 on Silesia: 17.1 → 40.6 MB/s (2.37×), and the ratio improved while doing it, 3.48× → 3.55×. Multi-core level 9 reaches 161.8 MB/s (auto) / 174.6 MB/s (8 threads).
Levels 16–22: an entropy-guided optimal parser
High levels now parse optimally instead of greedily: a dynamic-programming search (chunked at 4,096 positions so it stays in L2 cache) over exact binary-tree suffix matches, where every candidate is priced by an adaptive entropy model — 1/8-bit fixed-point probabilities that update online with Bayesian smoothing. The parser doesn't guess what a match costs; it asks the model that will actually encode it. Levels 12–15 get the exact tree matcher with lazy matching as well.
Level 19, multi-core: ratio 3.46× → 3.56× and speed 32.3 → 34.5 MB/s — in this benchmark, 11× faster than C libzstd's zstdmt at comparable settings.
Levels 1–4: learn to skip
Fast levels got refined double-fast probing and a statistical shortcut: SPRT-style adaptive skipping. When a region tests as high-entropy — already compressed, encrypted, random — the encoder stops hunting for matches that aren't there and strides forward. Level 1 encode: 242.2 → 284.2 MB/s (+17.3%); level 3: +11.2% at a 3.13× ratio, passing zstd-pure-rs.
Decode: two symbols per lookup
The Huffman decoder now uses an 11-bit dual-symbol table (decoding two symbols per lookup where the probability says it pays off), the FSE layer got exact cross-entropy mode selection and MDL-adaptive table accuracy, and length-limited Huffman construction is the proper O(n) Kraft-truncated algorithm. Decode on Silesia: level 3 806.5 → 878.0 MB/s (+8.9%), level 19 652.1 → 844.7 MB/s (+29.5%), passing structured-zstd.
One hardening fix worth naming: Huffman weight streams with a single weight describe an undecodable table, and the encoder now rejects them outright instead of emitting a stream nothing can read. The new adversarial test suite covers that, epoch wraparound at u32::MAX, the smallest window sizes across all 23 levels, and bidirectional interoperability with the zstd CLI — output stays wire-compatible in both directions.
Use it like this
use yolowzstd::{compress, decompress}; let compressed = compress(&data, 3); let restored = decompress(&compressed, data.len())?; [dependencies] yolowzstd = "0.1" Reusable Compressor/Decompressor contexts and multi-core execution are available via CompressOptions::new(level).with_threads(0).
Use yolowzstd when you need zstd in Rust without a C dependency and without unsafe — the mid levels are no longer a dead zone, and the read path got faster everywhere. If linking C libzstd is acceptable in your project, it remains the reference implementation and the thing these benchmarks chase; this crate exists for the projects where it isn't.
