Large language model (LLM) coding agents are increasingly operating at the repository level. While they can autonomously navigate codebases to fix bugs and add features, evaluating their ability to optimize entire codebases under realistic constraints remains a significant challenge.
FormulaCode is a new, large-scale benchmark designed to evaluate how well LLM agents can optimize real-world, repository-level codebases. By mining nearly 1,000 performance bottlenecks from scientific Python projects, researchers demonstrate that while frontier models can achieve non-trivial speedups, they still significantly underperform human experts—particularly when navigating complex architectural trade-offs.
The Problem: Correctness vs. Efficiency
We are entering the era of "agentic" coding, where LLMs do more than suggest snippets; they autonomously navigate entire repositories. However, most existing benchmarks for these agents focus on correctness (does the code pass a test?) rather than efficiency (how fast does it run?).
Real-world optimization is difficult. It is rarely about tuning a single isolated function. Instead, it requires understanding architectural decisions, component interactions, and "multi-objective" trade-offs—where improving one workload might inadvertently slow down another. Existing benchmarks are often too synthetic, rely on binary pass/fail signals, or operate at too small a scale to capture this complexity. FormulaCode fills this gap by providing a rigorous framework for measuring the full optimization lifecycle: triage, diagnosis, and resolution.
Methodology and Dataset
The authors developed an automated four-stage pipeline to construct the benchmark:
- Repository Scraping: They identified 766 GitHub repositories that use Airspeed Velocity (ASV), a tool for benchmarking Python packages.
- Attribute Filtering: They scraped over 100,000 pull requests (PRs), using LLMs to filter for those specifically intended to improve performance.
- Environment Synthesis: Because scientific Python often relies on compiled C/Fortran extensions, building the environment is non-trivial. The authors used a "reflexive LLM agent" to iteratively generate and fix Docker build scripts for each task.
- Statistical Validation: They applied expert patches to ensure each task represents a statistically significant performance improvement.
To measure success, the researchers introduced Agent Advantage, a metric that compares an agent's speedup against the speedup achieved by the original human expert. They also utilized Stratified Advantage to evaluate whether agents perform better at the module, class, or function level.
The resulting dataset, FormulaCode, contains 957 multi-workload optimization tasks mined from 70 diverse scientific Python repositories (e.g., Pandas, Scikit-learn, SciPy, Qiskit). To manage compute constraints, the primary evaluation in the paper utilizes FormulaCode-V, a curated subset of 108 tasks. Unlike existing benchmarks like SWE-bench (which focuses on correctness) and GSO-Bench (which focuses on single-function optimization), FormulaCode is unique in its "live" nature and its focus on multi-workload, repository-scale optimization.
Key Insights and Results
- Agents are "Micro-Optimizers": Models generally perform better at local, function-level optimizations. As the scope moves toward module-level architectural changes, their effectiveness drops compared to human experts.
- The "Expert Gap" in Trade-offs: Human experts are better at negotiating regressions. They might accept a small slowdown in one area to gain a massive speedup in another. Agents struggle to balance these competing objectives, often causing regressions that lead to their patches being rolled back.
- Global Performance: All evaluated agents achieved a speedup greater than 1, meaning they can improve code. However, the "Advantage" metric was negative across the board, indicating they are still not as capable as human contributors.
- Top Performers and Cost-Effectiveness: The combination of the OpenHands agent framework and Claude 4.0 Sonnet achieved the best results, particularly at module-level optimization. Furthermore, frontier models (like GPT-5 and Claude 4.0 Sonnet) proved more cost-effective overall. Even though they are more expensive per token, they solve tasks in fewer steps and with shorter reasoning chains than smaller, open-weights models.
- Correctness Violations: A major bottleneck is that roughly 48.5% of agent-generated patches were rejected because they broke functional correctness. Agents tend to spend more effort validating performance than verifying that the code still works.
- Strategy Matters: Agents excel at "low-hanging fruit" like parallelization or batching but struggle significantly when the solution requires delegating to lower-level system implementations (like C extensions or complex vectorized operations).
- Data Leakage: The authors found no consistent drop in performance for tasks created after the models' training cutoffs, suggesting the results reflect genuine reasoning capabilities rather than memorization.
Limitations and Future Work
The benchmark is currently limited to the scientific Python ecosystem (repositories using ASV). The authors suggest extending this to web frameworks, distributed systems, and other languages. Additionally, performance measurements were taken on specific AWS instances. While the "Advantage" metric is designed to be robust, cross-platform behavior remains untested.
Finally, the evaluation is only as good as the community-maintained ASV workloads; if a patch optimizes a path not covered by a benchmark, that gain goes unmeasured. Moving forward, the authors plan to expand the evaluation to the full 957-task set as more compute becomes available and to explore ensemble strategies that route different optimization scopes to different models.
Summary updated