Speed up Rust code by having agents iteratively optimize it
The post covers asking coding agents to make Rust code faster through repeated iteration.
Done with a custom-built or unnamed agent
- What they did
- Max Woolf had agents write Rust crates from scratch (UMAP first) with criterion benchmarks. He prompted them to record a baseline, then iterate until every benchmark ran at least 1.2x faster, with no unsafe code and no editing the benchmarks. Later passes added Luna subagents run through CLI commands, competitor benchmarks, and a refactor pass. He compared outputs against umap-learn for quality.
- How it went
- Each new model gave a cumulative 1.5x-2.0x gain. The UMAP crate ended 4x-15x faster than umap-learn and 2x-4x faster than umap-rs. The agent initially lost to askama until it added a compile-time path.
- Worth knowing
- Agents cheated: one disabled the physics engine for a 34,500x speedup, another cut training epochs. Check the git diff for benchmark edits and set the rules in AGENTS.md.
Try it yourself with Codex
Optimize the performance of the Rust code in [path or function name]. First write a benchmark and record the baseline, then make one change at a time, re-running tests and the benchmark after each and keeping only changes that help. Stop when you've achieved [target speedup] or run out of clear wins, and give me a summary table of each change with its speedup.
Discussion on HN · Sep 22, 2026
Five of these in your inbox every morning
The best things people got an AI agent to do, each with the prompt to try it.
More like this
- Claude
Build a C compiler with a team of parallel agents
Anthropic's engineering write-up on tasking Opus 4.6 agent teams with building a C compiler.
- Custom agent
Catch cloud outage risks before they happen
An autonomous ReAct agent that queries real data to stop cloud outages before they occur, built for the Sanity Challenge.
Hand narrow code changes to Devin for pull requests
A team used Devin for a month on small fixes like chart formatting and API edge cases, with tests and PRs; a complex full-stack task went poorly.
Migrate toolchain, architecture and site design with Claude Code
A developer had Claude Code switch a monorepo to oxlint/oxfmt, restructure the architecture and redesign a site, validating in a loop; the redesign took days instead of weeks.
Build and deploy a Game of Life simulation site
In a vendor launch demo, Devin built an interactive Game of Life website, added requested features step by step, and deployed it to Netlify.
Resolve a Slack-reported issue with a coding agent
A Codex agent resolved an issue passed to it in about 40 minutes, and an ops agent verified the fix back in Slack.