Rust code optimization driven by AI agents has hit another round of gains. A developer who had already tuned several Rust libraries with OpenAI models reports a cumulative 4x average speedup after adding passes with Anthropic’s Opus 5.5 and Fable 5.2, along with much lower memory use. Their word cloud generator now runs in 374 microseconds.
The pipeline and the first pass
The setup is an iterative loop: an agent is told to speed up benchmarks by a set amount without regressions or cheating, with checks to keep code quality up. Earlier runs mostly used GPT models. When the developer fed their updated prompt to Opus 5.5, a single pass delivered 1.2x to 1.5x speedups on several projects that GPT 6.1 Astra had already optimized.
The tooling took some adapting. Opus 5.5 spins up background tasks and subagents, which suits long benchmark runs but displayed poorly in Zed Agent, so the developer settled on the desktop Claude app. It lists background tasks, shows usage limits and has Remote Control for hours-long prompts. Claude Code also pipes criterion output to a temporary file, so intermediate benchmark results aren’t visible until a run ends.
Two habits stood out. Opus writes more code than the GPT models: when a hot path used the png crate, it built its own PNG module for 1.2x to 1.5x gains. It also profiles early with samply and re-profiles after every change, where the GPT models mostly ignored profiling hints.
Memory, visuals and disassembly
The developer wants more than a faster-than-state-of-the-art result: they want code pushing against hardware limits, with benchmarks measured in microseconds rather than milliseconds, even for light software such as word clouds and ASCII art. That ambition drove each extra pass of Rust code optimization.
A plain prompt, “do a pass to reduce peak memory consumption without causing significant regressions,” cut peak memory across projects, mostly through streaming and better Vec sizing. Speed gains from it were rare.
Visual quality improved too. The developer’s Rust UMAP crate beat umap-learn by 4x to 15x but produced less distinct clusters on MNIST. After a pass targeting cluster quality, the lead over umap-learn fell to about 4x with comparable results. A raster-to-vector crate that had been shelved over color blotches and jagged staircases now beats vtracer and img2svg on speed, fidelity and file size. One pelican test image shrank from 25KB to 14KB after a separate compression tool.
The most surprising pass required every library change to be justified by disassembling the compiled binary, aiming at fewer instructions and less branching. Opus 5.5 produced Rust changes that cut emitted instructions without regressions. The developer warns it may overfit to their M3 MacBook Pro and ARM, although the diffs look architecture agnostic, and the agent avoided unsafe custom instructions.
What Fable 5.2 added
Fable 5.2 arrived a couple of weeks before the write-up. The developer had spare quota and ran it through the same steps as Opus 5.5.
Fable 5.2 looked only okay on paper, costs more and can use only half of the Claude Code weekly quota. Run at high effort with Opus 5.5 subagents, it still delivered 1.5x to 2.0x speedups on many projects, above the 1.2x to 1.5x typical of each earlier release.
It also produced byteseek, a Rust search tool the developer says beats ripgrep on synthetic in-memory benchmarks. The developer ran apples-to-apples CLI tests on synthetic and real data, since ripgrep’s own benchmarks use the Linux source tree and OpenSubtitles. They’re releasing byteseek as an early research preview, with human-readable output, jq-like JSON, YAML and TOML search, fuzzy matching and Python bindings that beat pyahocorasick and orjson.
The five-pass recipe and what’s next
- An Opus 5.5 speed pass with the updated prompt.
- An Opus 5.5 peak-memory pass.
- An Opus 5.5 disassembly pass.
- A Fable 5.2 speed pass.
- An optional Fable 5.2 disassembly pass, quota permitting.
The developer says results reproduced across projects, including a statistical modeling library and a data visualization library. Most are now at what Opus judges to be theoretical limits.
For anyone repeating this, the lesson is that Rust code optimization with agents keeps paying off after the obvious gains, if the prompts add profiling, memory and disassembly passes.
The libraries themselves aren’t public yet. The developer wants more real-world testing first, and doesn’t want to release code just before another model finds a 2x gain. For now, only byteseek is open source.
Source: Max Woolf's Blog