[PR #791] [MERGED] Compression: flate2's zlib-rs backend instead of miniz_oxide #2814

Closed
opened 2026-11-02 15:59:16 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/791
Author: @ludovic111
Created: 10/18/2026
Status: ✅ Merged
Merged: 10/18/2026
Merged by: @ludovic111

Base: main ← Head: perf/zlib-rs


📝 Commits (1)

  • a2f8952 Compression: flate2's zlib-rs backend instead of miniz_oxide

📊 Changes

3 files changed (+3 additions, -3 deletions)

View changed files

📝 crates/horizon-client/Cargo.toml (+1 -1)
📝 crates/horizon-protocol/Cargo.toml (+1 -1)
📝 crates/horizon-world/Cargo.toml (+1 -1)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

What

flate2 now uses its zlib-rs backend, with runtime_detection for SIMD, in place of rust_backend (miniz_oxide). The change is in horizon-client, horizon-protocol and horizon-world. Cargo.lock doesn't change, because zlib-rs 0.6.8 was already in the tree.

Why

The server compresses every packet over the threshold, and every chunk, with deflate. #748 made fewer packets go through it. This PR makes each one that still does cost less: packets under 8 KiB, and chunks that only one player receives.

Numbers

Deflate micro-benchmark on 624 MB of real chunk NBT from a bench world. CPU seconds over 3 rounds, with the load phase subtracted:

miniz_oxide zlib-rs change
whole chunks 6.32 s 3.19 s 1.98× faster
256 B – 8 KiB slices 6.83 s 5.46 s 1.25× faster
load phase (includes inflate) ~0.96 s ~0.71 s
output size, chunks 70.84 MB 72.68 MB +2.6%
output size, slices 87.28 MB 88.41 MB +1.3%

Every compressed buffer inflated back to its input.

Server A/B on main 9b97ba09: 30 explore bots at 6 blocks/s, base and new run at the same time on the Mac mini:

base r1 new r1 base r2 new r2
CPU 156.9% 152.0% 150.9% 149.7%
chunks/s 217.9 213.7 216.1 214.9
MSPT 96.6 88.2 97.7 89.3
deflate samples, lan-out writer 4792 1763 4787 1919

Deflate time on the writer thread falls by about 60%. The output is about 2% larger. Every reader inflates it the same way, since the format and the compression threshold are unchanged.

How tested

  • cargo fmt --all --check: passes.
  • cargo clippy --workspace --all-targets -- -D warnings: passes.
  • cargo test -p horizon-protocol -p horizon-world: 215 passed, 0 failed.
  • tools/parity.py --changed origin/main: 222 of 222 harnesses pass.
  • tools/parity.py dedicated_server lan: both pass. Vanilla and Horizon clients join a Horizon server and decode its compressed chunks and packets.

Needs Ludovic

Nothing.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/791 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/18/2026 **Status:** ✅ Merged **Merged:** 10/18/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/zlib-rs` --- ### 📝 Commits (1) - [`a2f8952`](https://github.com/horizon-rust/horizon/commit/a2f8952d05484387833d693de8b78a61d7f0697a) Compression: flate2's zlib-rs backend instead of miniz_oxide ### 📊 Changes **3 files changed** (+3 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/Cargo.toml` (+1 -1) 📝 `crates/horizon-protocol/Cargo.toml` (+1 -1) 📝 `crates/horizon-world/Cargo.toml` (+1 -1) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What flate2 now uses its `zlib-rs` backend, with `runtime_detection` for SIMD, in place of `rust_backend` (miniz_oxide). The change is in horizon-client, horizon-protocol and horizon-world. `Cargo.lock` doesn't change, because zlib-rs 0.6.8 was already in the tree. ## Why The server compresses every packet over the threshold, and every chunk, with deflate. #748 made fewer packets go through it. This PR makes each one that still does cost less: packets under 8 KiB, and chunks that only one player receives. ## Numbers Deflate micro-benchmark on 624 MB of real chunk NBT from a bench world. CPU seconds over 3 rounds, with the load phase subtracted: | | miniz_oxide | zlib-rs | change | |---|---:|---:|---| | whole chunks | 6.32 s | 3.19 s | 1.98× faster | | 256 B – 8 KiB slices | 6.83 s | 5.46 s | 1.25× faster | | load phase (includes inflate) | ~0.96 s | ~0.71 s | | | output size, chunks | 70.84 MB | 72.68 MB | +2.6% | | output size, slices | 87.28 MB | 88.41 MB | +1.3% | Every compressed buffer inflated back to its input. Server A/B on main 9b97ba09: 30 explore bots at 6 blocks/s, base and new run at the same time on the Mac mini: | | base r1 | new r1 | base r2 | new r2 | |---|---:|---:|---:|---:| | CPU | 156.9% | 152.0% | 150.9% | 149.7% | | chunks/s | 217.9 | 213.7 | 216.1 | 214.9 | | MSPT | 96.6 | 88.2 | 97.7 | 89.3 | | deflate samples, lan-out writer | 4792 | 1763 | 4787 | 1919 | Deflate time on the writer thread falls by about 60%. The output is about 2% larger. Every reader inflates it the same way, since the format and the compression threshold are unchanged. ## How tested - `cargo fmt --all --check`: passes. - `cargo clippy --workspace --all-targets -- -D warnings`: passes. - `cargo test -p horizon-protocol -p horizon-world`: 215 passed, 0 failed. - `tools/parity.py --changed origin/main`: 222 of 222 harnesses pass. - `tools/parity.py dedicated_server lan`: both pass. Vanilla and Horizon clients join a Horizon server and decode its compressed chunks and packets. ## Needs Ludovic Nothing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 15:59:16 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#2814
No description provided.