Skip to content
agentusehub

Speed up Rust code by having agents iteratively optimize it

The post covers asking coding agents to make Rust code faster through repeated iteration.

Time saved
Not reported
Setup time
Not reported
Running cost
Not reported
Cost range
Not reported

Use case overview

The post covers asking coding agents to make Rust code faster through repeated iteration.

Reported experience

  1. 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.

  2. 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.

  3. 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.

Example prompts

Try 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.
Software & DevOps

Port a Chrome extension to Safari

The author had ChatGPT take the Session Buddy extension source from Chrome, port it to Safari and install it, taking about 20 minutes.

ChatGPT