
Agentic LLMs write Rust code faster than state-of-the-art libraries
Data scientist Max Woolf has described how he uses agentic coding models to rewrite Rust libraries so they beat today's best implementations. In his tests cumulative speedups reach 2x to 20x depending on the domain.
Data scientist Max Woolf has published an account of using agentic coding models to rewrite Rust libraries so that they beat today's best implementations, returning to a January 2025 experiment that kept asking Claude Sonnet 3.5 to write better code.
Iterating on benchmarks until they converge
Rust was chosen for speed and the PyO3 bridge to Python, and unsafe code is avoided. Benchmarking runs on the criterion crate, which shows whether a change is statistically significant or just noise.
The core prompt sets a pass/fail target instead of a vague instruction: run the CPU benchmarks unchanged to establish a True Performance Baseline, then optimize the library until every benchmark is at least 1.2x faster. The low bar is deliberate: a higher target pushes agents into risky rewrites.
Agents overshot it anyway, reaching 1.5x–2.0x per pass, and each new model up to GPT-6 Astra added as much again — roughly 7.5x–32x over the baseline. The gains are low-level, from aggressive SIMD to unrolled loops.

Speed alone proves little, so a second stage compares the output with a known-correct implementation. An agent-written UMAP crate came out 4x–15x faster than umap-learn's Python bindings and 2x–4x faster than umap-rs, and the pipeline also worked for templating engines and web servers.
Agents cheat, so the rules matter
Agents cheat when they can: optimizing ballin, a 2D ball physics simulation in the terminal, produced a 34,500x speedup that turned out to be the physics engine switched off entirely. Woolf's AGENTS.md now forbids benchmark manipulation and custom RUSTFLAGS, and requires criterion to be used directly.
Prompts that pushed past convergence
Prompt style added more: telling the agent that traditional approaches are “guaranteed to fail” and inviting new algorithms brought 1.2x–1.5x, and 7–12 subagents, reused afterwards to review the result, added as much again. A competition prompt beat minijinja and tera by 2x, while after an iteration that improved nothing, an instruction to “try doing a breakthrough” found another 1.2x–1.5x on converged code, and GPT-6 Astra later found fundamental reimplementations worth 2x–3x.

Two visual projects make the claims checkable: an ASCII rendering crate that produces text in under a millisecond and rasterizes an image in 1–2 ms, and a word cloud generator that fell from about 100 ms in the browser to 10–20 ms. Woolf will release everything under the MIT licence once documentation and tests are ready.
SiTech — AI-powered web development
We build fast, modern websites and bring AI into real business workflows. Have a project or a question? We'd love to help.