Conao3 Notes

Speeding Up zstd-rs Without Writing Code by Pairing Local and Web Gemini 4 Neon

I prepared a WebAssembly performance proposal for Shiguredo's Pure Rust Zstandard library shiguredo/zstd-rs. Upstream merged those ideas into the optimization commit and listed my name under Performance Contributors in the README. My own role stopped at linking local Gemini 4 Neon to a 10-agent Web Gemini 4 Neon swarm and issuing six short prompts to delegate verification to separate model families. I wrote zero lines of Rust.

The companion post Optimizing Pure Rust Zstd in WebAssembly to 89% of Emscripten Without Unsafe covers the data structures, loop splits, and ablations behind the speedup. From the maintainer side, voluntas wrote zstd-rs に性能改善提案をいただいて約 2 倍早くなった (in Japanese), covering Shiguredo's benchmark setup and review process.

Two posts that started the experiment

Two posts on X kicked this off. In the first, voluntas at Shiguredo invited WebAssembly speed proposals for zstd-rs under strict rules: keep #![forbid(unsafe_code)], #![no_std], zero dependencies, and equal or better compression ratio on Chromium benchmarks.

That same morning, Ryu posted a workflow that spawns 10 Gemini 4 Neon sub-agents in parallel inside the Gemini web app. Web Gemini draws from a separate quota from local Antigravity, so offloading exploration and design generation to the web while driving verification from local agents looked like a strong test case.

Six prompts from start to finish

The work spanned two threads, yet I typed six prompts in total. Agents handled code reading, WebAssembly builds, Chromium benchmarks, and test suites.

img

In the first thread, I pasted voluntas's post URL and told local Gemini 4 Neon: "Do this. Consult a Fable-class model and produce results worth reporting."

My local environment runs inside T3 Code, which lets Gemini 4 Neon delegate reviews and verification to Claude Fable 5.2 via Claude Code and GPT-6.2 Astra via Codex. Local Gemini 4 Neon measured the shiguredo/zstd-rs baseline, collected a V8 CPU profile, asked GPT-6.2 Astra to review the optimization plan, and ran six iterations with critical reviews from Claude Fable 5.2.

Midway through, I opened a second thread and asked the agent to replicate Ryu's swarm setup by handing the current zstd-rs bottlenecks to Web Gemini 4 Neon.

Once the 10-agent web swarm returned a 39 KB design document, I told the local side: "Checking this with Neon again adds little value, so launch a Fable-class model on the local side to bring a different perspective."

Next, I asked: "Merge into this thread for maximum performance. You can settle the source thread." That combined both threads into one workspace.

After the final patch passed benchmarks and tests, I asked: "Fork the repo and put it in a state the maintainer can merge. It is on GitHub, right?"

The agent tried to open a pull request, saw that upstream disables pull requests, and reported back. I replied: "Put this PR body in a secret Gist viewable by link." I then posted the fork branch and Secret Gist URLs in the Shiguredo community Discord.

Refuting the 10-agent web swarm with separate model families

To run the web swarm, the local agent uploaded the source tree through the browser and triggered Task mode with 10 parallel sub-agents. Five agents focused on the encoder, while five audited the decoder and WebAssembly constraints, returning one consolidated design document.

Letting the same model implement and review its own design lets blind spots pass unchecked. Instead, I had local Gemini 4 Neon launch Claude Fable 5.2 and GPT-6.2 Astra in turn as independent verifiers, measuring each idea one by one in interleaved Chromium wasm-bench runs.

This cross-model check dropped several ideas that looked sound on paper yet regressed on real hardware.

  • Single-stream sequential Huffman decoding aimed to cut register spills, yet it broke CPU instruction-level parallelism and dropped decode speed from 427.7 MiB/s to 395.1 MiB/s, so we cut it.
  • Writing compressed blocks straight into the output buffer and pre-allocating scratch space disturbed the WebAssembly allocator layout and doubled standalone linear memory from 69.188 MiB to over 135.688 MiB, so we cut both.
  • Skipping long-distance 4-byte matches had zero effect because matches of length 6 or less accounted for 0.0% in the 7-byte hash path, so we cut it.

Claude Fable 5.2 also caught a bug from an earlier iteration where clamp panicked on single-segment frames under 256 bytes, and fixed it. The same pass removed a 128 KiB zero-fill bug on small compressed blocks.

Handing audits and measured ablations to different model families caught both speed regressions and panic bugs before I shared the proposal.

Benchmark results and upstream integration

The table below compares interleaved local Chromium runs of my fork branch commit 92aa3fc against baseline commit 3894aa1. The test machine ran NixOS on an Intel Core i5-8400 with Chromium 158 and Rust 1.100.1 targeting wasm32-unknown-unknown, over six Silesia corpus files totaling 46,855,742 bytes.

Metric Baseline 3894aa1 Proposal 92aa3fc Change Emscripten Level 1 (same run)
Compression speed 124.8 MiB/s 190.4 MiB/s +52.6% 223.3 MiB/s
Decompression speed 279.4 MiB/s 476.9 MiB/s +70.7% 537.1 MiB/s
Compressed size 15,764,178 B 15,727,940 B -36,238 B 17,116,627 B
Standalone wasm size 93,642 B 99,731 B +6,089 B -
Standalone linear memory (post-decode) 144.063 MiB 69.188 MiB -52.0% 107.563 MiB

To check safety, GPT-6.2 Astra ran 87,228 mutated-frame differential tests and 1,747 post-error decoder reuse tests with zero output mismatches, zero error-kind mismatches, and zero panics. Compressed outputs matched byte for byte between native and WebAssembly across all six files, and all 95 tests, including libzstd interop tests, passed.

Upstream shiguredo/zstd-rs disables external issues and pull requests and coordinates through Discord. I shared the proposal writeup as a Secret Gist alongside the fork branch URL in the Shiguredo community Discord.

In that channel, cp-20 and serinuntius shared their own proposals from the same call, and voluntas combined ideas from all three while verifying with fuzzing. That fuzzing run uncovered an integer underflow bug still sitting in my proposal branch when a 2-byte sequence count produces nb_sequences of 0. Upstream resolved that bug with the fix cp-20 had built.

Multiple contributors shared rough proposals through forks and Gists while the maintainer verified and merged the strongest parts. Those combined optimizations landed in upstream commit 2b5fd0b35e, and Shiguredo removed the README warning that zstd-rs took almost twice as long as the Emscripten build.

Upstream GitHub Actions benchmarks report 201.7 MiB/s compression, 447.7 MiB/s decompression, and 63.375 MiB linear memory after aggregate decoding. Shiguredo also shipped this improvement in their browser storage engine shiguredo/ake.

Closing

My work came down to stating constraints, widening ideas with the web swarm, and sending each candidate to separate model families for measured verification. The companion post explaining the technical optimizations breaks down the exact data structures, loop splits, and rejected ablations in the proposal branch.