Skip to content

Inflate with flate2's zlib-rs backend - #5

Merged
xbmc4lyfe merged 1 commit into
mainfrom
claude/zlib-rs
Nov 6, 2026
Merged

xbmc4lyfe merged 1 commit into
mainfrom
claude/zlib-rs

Conversation

@xbmc4lyfe

Copy link
Copy Markdown
Collaborator

What

  • Backend. flate2 now runs on its zlib-rs backend, a Rust port of zlib, instead of its default miniz_oxide. It uses default-features = false, features = ["zlib-rs", "runtime_detection"].
  • SIMD detection. runtime_detection turns on zlib-rs's std feature, so it detects the CPU's SIMD support (AVX2 and BMI on x86-64) at runtime. Without it the x86 gain was only about 15%.
  • Dependencies. The tree goes from six crates to two: flate2 and zlib-rs. miniz_oxide, adler2, simd-adler32, crc32fast and cfg-if are gone. Cargo.lock and fuzz/Cargo.lock are updated.
  • Docs. Unlike miniz_oxide, zlib-rs uses unsafe internally for its SIMD paths. The README's Design section, the crate docs' Hardening section and the Cargo.toml comment now say so. zipview's own code is still #![forbid(unsafe_code)].

Measured (fastest round, examples/bench.rs)

case M4 Air M5 Air (load ~130–180) i7-8700K (load ~26)
inflate-16M 908–925 → 2245–2357 MB/s 406–475 → 1386–1596 MB/s 681–687 → 1998–2099 MB/s
inflate-2000x4K 412–421 → 864–935 MB/s 188–219 → 409–519 MB/s 250–309 → 587–639 MB/s
  • Stored reads and opening the directory are unchanged.
  • An x86-64-v3 build of the zlib-rs version runs the same as the default build (2.13 vs 2.14 GB/s in interleaved runs), since the SIMD paths are chosen at runtime either way.

Correctness

  • The whole suite passes unchanged, including inflate_holds_streams_to_their_declared_size. That test covers too-long, too-short, truncated, trailing-junk and garbage streams.
  • cargo fmt --check, cargo clippy --all-targets -- -D warnings, cargo test and cargo test --doc pass on aarch64-apple-darwin and x86_64-linux.

🤖 Generated with Claude Code

flate2 now runs on zlib-rs, a Rust port of zlib, instead of its default
miniz_oxide, with runtime_detection so zlib-rs picks its SIMD paths (AVX2 on
x86-64) on the machine it runs on. The dependency tree goes from six crates to
two (flate2, zlib-rs). Unlike miniz_oxide, zlib-rs uses unsafe internally; the
README, crate docs and Cargo.toml now say so, and zipview's own code still
forbids it. 16 MiB of text: M4 925 -> 2357 MB/s, i7-8700K 681 -> 2099; 2,000
entries of ~4 KiB: M4 421 -> 935 MB/s, i7-8700K 250 -> 639.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-06T19:34:12.986142Z 5a18c7c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@xbmc4lyfe
xbmc4lyfe merged commit 0da04d6 into main Nov 6, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant