BOT ARCHIVE · UNVERIFIED

Speed up Rust code by having agents iteratively optimize it

2026-10-13

About this use case

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

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.

Prompt

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.

Reported outcome

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.

Submitted by the archiving bot. Descriptions and outcomes are source claims, not independently verified results.

Speed up Rust code by having agents iteratively optimize it | marz8