SWE-fficiency: Can Language Models Optimize Real-World Repositories on Real Workloads?

Jeffrey Jian Ma, Milad Hashemi, Amir Yazdanbakhsh, Kevin Swersky, Ofir Press, Enhui Li, Vijay Janapa Reddi, Parthasarathy Ranganathan

Abstract While Large Language Models (LLMs) have demonstrated remarkable proficiency in resolving functional bugs, software engineering extends beyond mere correctness—it demands efficiency. SWE-fficiency is a novel benchmark designed to evaluate whether AI agents can autonomously optimize the performance of real-world software repositories. Across 498 tasks from nine major Python libraries, state-of-the-art models currently achieve less than 23% of the speedups realized by human experts, highlighting a significant gap in long-horizon software reasoning and performance engineering.

The Challenge: From "What to Fix" to "How to Fix It Well"

In recent years, benchmarks like SWE-bench have proven that LLMs can successfully navigate codebases to fix bugs or add minor features. However, performance engineering is a fundamentally different and more complex skill. It requires an engineer to profile workloads, identify bottlenecks, understand cross-functional semantics, and implement structural changes that reduce runtime without altering the program's behavior.

Most existing benchmarks focus on functional correctness. As hardware scaling limits approach, the ability to autonomously optimize code efficiency is becoming a critical, high-value necessity. SWE-fficiency shifts the focus from simple issue resolution to repository-level performance optimization on real workloads.

The SWE-fficiency Benchmark

To evaluate "how-to-fix" capabilities, the researchers developed an automated pipeline to scrape GitHub for real-world, performance-improving Pull Requests (PRs). The resulting benchmark comprises 498 tasks across nine iconic, high-performance Python libraries, including NumPy, Pandas, SciPy, scikit-learn, Matplotlib, Dask, Astropy, SymPy, and xarray.

The dataset curation relied on a rigorous, multi-stage validation process:

  1. Attribute Filtering: Identifying PRs with performance-related keywords (e.g., "speedup," "perf") that modified code without altering existing unit tests.
  2. Static & Coverage Analysis: Utilizing tools like coverage.py and jedi to verify that existing tests exercised the modified code.
  3. Execution Validation: Running the expert patch in a controlled Docker environment to confirm a statistically significant speedup.

To quantify performance, the authors introduce the Speedup Ratio (SR). If a human expert makes a function 5x faster and an AI agent makes it 1.2x faster, the SR is 0.24. This metric provides a long runway for future AI progress, allowing models to eventually surpass human baselines (SR > 1.0).

Key Insights: Where AI Agents Fall Short

Empirical evaluations reveal that current AI agents struggle significantly with performance engineering, exhibiting several distinct failure modes:

  • Shortcut Bias: Rather than implementing principled structural improvements—such as restructuring data flows or moving loops into compiled backends like Cython—LLMs tend to apply "band-aid" fixes. They frequently rely on localized caches or early-exit conditions.
  • The Localization Gap: While models are adept at identifying the correct file to edit, they often fail to pinpoint the specific function causing the bottleneck. Over 68% of expert performance gains occurred in functions that the LLMs completely ignored.
  • Satisficing: Agents frequently settle for the first minor speedup they discover. Instead of iterating to find the optimal path, they "satisfice" and halt their optimization efforts prematurely.
  • Workload Overfitting: Some models generate fragile code by hardcoding optimizations tailored to the specific data shapes or types present in the test workload, which would likely fail in production environments.

Quantitative Results

The performance gap between AI agents and human experts remains massive. Across 15 frontier models evaluated, the average performance was less than 0.23x of the expert baseline.

Currently, Claude 4.5 Opus leads the benchmark with an SR of 0.225x, followed by GPT-5 at 0.157x. Furthermore, optimization proved risky for these models: many proposed "faster" patches that broke existing unit tests, failing the benchmark's strict pass-to-pass correctness requirement. The data also showed an inverse relationship between task difficulty and model success; as the human-achieved speedup grew larger, LLM performance dropped, indicating an inability to formulate deep algorithmic insights.

Limitations and Future Directions

Currently, SWE-fficiency is limited to the Python and Cython ecosystems. While these languages form the backbone of modern data science and AI, extending the benchmark to lower-level systems languages like C++ or Rust would provide a more comprehensive evaluation of systems engineering capabilities.

Additionally, the benchmark focuses solely on runtime optimization. Future iterations could introduce multi-objective targets, such as minimizing memory usage or energy consumption. To close the gap with human experts, future AI agents will require more robust, integrated profiling tools and improved "don't-stop-early" reasoning loops to prevent premature satisficing.

Summary updated

BibTeX
@inproceedings{ma2026swe,
  author = {Jeffrey Jian Ma and Milad Hashemi and Amir Yazdanbakhsh and Kevin Swersky and Ofir Press and Enhui Li and Vijay Janapa Reddi and Parthasarathy Ranganathan},
  title = {{SWE-fficiency: Can Language Models Optimize Real-World Repositories on Real Workloads?}},
  booktitle = {International Conference on Machine Learning},
  year = {2026},
  url = {https://openreview.net/forum?id=0pyFbZSfbT},
}
Figure