Writing Rust code that's faster than state-of-the-art…

minimaxir.com

Written by AI

TLDR
Max Woolf shows agents repeatedly optimizing Rust benchmarks by 2× to 20× with baselines, explicit targets, correctness gates, and anti-cheating constraints.
Best for
Engineers running benchmark-driven optimization loops with coding agents
The tip
Set a true baseline, require a measurable speedup, preserve correctness, and audit the benchmark diff for gaming.
What you need
  • A representative benchmark suite
  • A known-correct implementation or quality gate
  • Sequential benchmark runs
  • Repository guardrails
Start here
  1. Record the true baseline before edits
  2. Set a modest pass/fail target
  3. Re-run correctness checks and inspect every benchmark change
Filed note
Max Woolf shows how benchmark-driven agent loops produced 2–20× Rust speedups, with explicit baselines, pass/fail targets, and guardrails against gaming the tests.

articleThe source

Highlights
  • After months of testing and experimenting since the release of Opus 4.5 made agentic coding more viable, I can confidently confirm that modern agentic LLMs can indeed write Rust code that is significantly faster than current state-of-the-art approaches if given appropriate guardrails and constraints.

    The gains depend on explicit guardrails, not open-ended prompting.

  • What I needed was a clear target goal that can be pass/failed, so I refined the prompt:

    A measurable target kept the optimization loop moving.

  • It must be reiterated that agents can and will cheat if they can.

    Benchmark integrity needs its own rules and review.

Excerpt

In January 2025, I had a fun hypothesis for a blog post: can LLMs write better code if you keep asking them to “write better code”? That was prior to the advent of robust agentic coding, but Claude Sonnet 3.5 was still able to iteratively improve on algorithmic Python code.

From minimaxir.com

Read the full article