Max Woolf did something quietly clever: he didn't tell an AI agent how to optimize Rust code. He just said "make it faster," then let the agent rewrite code, run benchmarks, and decide what to keep.
After seven iterations, the result wasn't the "AI writes SIMD black magic" story people might expect. Instead, the experiment surfaced a bunch of engineering details that are easy to overlook. The original post lives at minimaxr.com/2026/09/agentic-iteration, and it made the Hacker News front page with 78 points and 38 comments.
How the experiment worked
Woolf kept the prompt deliberately minimal. The instruction wasn't "use SIMD" or "reduce allocations." It was a single open-ended goal:
Make this Rust program faster.
The agent then ran its own loop:
- Read the current code
- Form an optimization hypothesis
- Modify the code
- Run a benchmark (Woolf used criterion, the standard Rust bench tool)
- Compare numbers and keep the better version
A full loop takes about 5–10 minutes. Woolf set a hard cap: stop after seven iterations. No human intervention, no nudging the agent in any direction.
The design's value isn't in the cleverness of the prompt. It's in whether there's reliable verification. Criterion produces the numbers. The machine reads them and the machine judges. The agent doesn't need a human to tell it whether an optimization worked — the numbers speak for themselves.
Did the agent find bottlenecks humans would miss?
Across seven rounds, the agent produced a pile of optimizations. A representative sample:
Category 1: Allocation strategy
- Replacing
Vec::pushwith pre-allocatedVec::with_capacity - Swapping frequent small allocations for
SmallVecor an arena allocator - Switching string concatenation from
format!toString::with_capacityplus manualpush
Category 2: Zero-cost abstraction swaps
- Replacing trait objects (
dyn Trait) with enum dispatch to avoid dynamic dispatch - Breaking iterator chains into explicit loops so the compiler can inline more aggressively
- Rewriting
Option<Box<T>>asOption<NonNull<T>>— unsafe, but tighter
Category 3: Data layout
- Reordering struct fields so hot fields share a cache line
- Using
#[repr(C)]to control ABI layout - Aligning to cache line boundaries with
#[repr(align(N))]
Sounds reasonable. But here's the question: which of these would a beginner miss, and which would any experienced Rust dev spot immediately?
The honest answer: the first two categories are textbook optimizations. Anyone with six months of Rust knows with_capacity beats push. Trait-object-to-enum is on the first page of the Rust performance wiki.
Category 3 — data layout — is the genuinely interesting one. That's something you usually need a profiler to discover: you have to know which struct fields are hot and which are cold before you can judge whether reordering helps. The agent here didn't actually run perf. It leaned on common-sense assumptions, and the hit rate was uneven.
What happened across the seven iterations
The numbers didn't climb monotonically. Two events stand out:
Plateau. Between rounds 4 and 5, nothing meaningful changed. The agent's proposed "optimization" landed inside the benchmark's noise floor. Instead of thrashing, it changed direction.
Rollback. In round 6, the agent introduced what looked like a cleaner version — wrapping an unsafe block behind a safe API. The benchmark got 8% slower. The agent reverted it on its own.
These two moments matter more than any headline speedup number.
First, the agent doesn't run on intuition. It runs on numbers. It doesn't know that an optimization "should" be faster in theory — it trusts the benchmark. That's why it doesn't push through a plateau, and that's why it doesn't argue when something regresses.
Second, benchmark noise is a real problem. Criterion's default 5% noise threshold means the agent can't even detect improvements under 5%. Rust's "last 5%" of performance work is effectively invisible to this kind of loop.
Third, safety abstractions aren't free. Rust's safe wrappers aren't free — they add a layer of bound checks, a layer of panic branches. Unsafe code written correctly is zero-cost; wrap it in a safe API and the cost returns. What the agent bumped into here isn't stupidity — it's a fundamental property of Rust's safety model.
How this differs from Cursor or Copilot
The key distinction isn't "which model is stronger." It's who owns the loop.
Cursor and Copilot have a core interaction shape:
- The human writes code; AI completes
- The human hits tab; AI suggests
- The human decides whether to accept
The subject of the loop is the human. The AI is a tool.
Woolf's experiment flips that. The subject of the loop is the agent:
- Agent reads code
- Agent modifies code
- Agent runs benchmarks
- Agent decides what to keep
The human glances at the result at the end.
The agent here didn't write large new features — every change was a small rewrite verified by benchmark. That points at a counter-intuitive direction: the core capability of future coding agents won't be "how fast can you write," but "how stable can your loop run."
Writing code is a single decision. A loop is many decisions plus state management plus error recovery. The latter is much harder.
What this means for Rust performance engineering
The Rust community has traditionally been about humans hand-squeezing SIMD bytes. Watch any Rust performance talk and the speaker is showing how to hand-write unsafe, how to use #[repr(align)], how to drop into std::arch::asm!.
If an agent can automate 70% of routine optimizations — allocation patterns, iterator rewrites, trait-object swaps — the engineer's job collapses to two things:
- Designing the benchmark
- Defining the goal
Not writing the code itself.
The transition sounds obvious, but it hides a premise: the benchmark has to be right.
If the benchmark is wrong, the agent will happily optimize a scenario that doesn't matter. You think you're telling it to optimize the "real usage" path, but it's actually tuning itself to a micro-task inside the benchmark. That's garbage-in / garbage-out, and AI won't fix it for you.
Editorial thought
The more interesting point than "AI writes code" is this: the value of agentic coding doesn't come from generation. It comes from the verification loop.
An agent that runs its own tests, reads its own numbers, and reverts its own regressions is closer to an "automated engineer" than an agent that can crank out 1000 lines. The former outsources human judgment to the machine's objective measurements. The latter just outsources typing speed to the machine's probabilistic sampling.
But — and this is the catch — the benchmark still has to be right, which puts the burden right back on the human.
A more contrarian observation: Woolf's experiment may be most valuable not as a demonstration that "Rust agents can optimize Rust," but as evidence of where agentic loops fail without ground truth. Rust performance has benchmarks as ground truth, so the loop works. Design decisions, product strategy, user research — none of those have ground truth, and an agentic loop in those domains just spins its wheels.
Over the next 12–18 months, the metric worth watching isn't "which agent writes code faster." It's which domains can build reliable verification loops. In the ones that can't, an agent is just another way to burn out a team.