Learning Performance-Improving Code Edits

Aman Madaan, Alexander Shypula, Uri Alon, Milad Hashemi, Parthasarathy Ranganathan +3 more
2/12/2026

No official code found. Best implementation: madaan/pie-perf (101 stars, last commit 2024-04-16).

Abstract

The waning of Moore's Law has shifted the focus of the tech industry towards alternative methods for continued performance gains. While optimizing compilers are a standard tool to help increase program efficiency, programmers continue to shoulder much responsibility in crafting and refactoring code with better performance characteristics. In this paper, we investigate the ability of large language models (LLMs) to suggest functionally correct, performance improving code edits. We hypothesize that language models can suggest such edits in ways that would be impractical for static analysis alone. We investigate these questions by curating a large-scale dataset of Performance-Improving Edits, PIE. PIE contains trajectories of programs, where a programmer begins with an initial, slower version and iteratively makes changes to improve the program's performance. We use PIE to evaluate and improve the capacity of large language models. Specifically, use examples from PIE to fine-tune multiple variants of CODEGEN, a billion-scale Transformer-decoder model. Additionally, we use examples from PIE to prompt OpenAI's CODEX using a few-shot prompting. By leveraging PIE, we find that both CODEX and CODEGEN can generate performance-improving edits, with speedups of more than 2.5x for over 25% of the programs, for C++ and Python, even after the C++ programs were compiled using the O3 optimization level. Crucially, we show that PIE allows CODEGEN, an open-sourced and 10x smaller model than CODEX, to match the performance of CODEX on this challenging task. Overall, this work opens new doors for creating systems and methods that can help programmers write efficient code.

View on arXivView PDF

Code Implementations(1)

madaan/pie-perfCommunity100%

Training language models to make programs faster

10115C++, PythonFeb 13, 20232 years ago
code-generationcode-optimizationllmsoptimizationsoftware-engineering

Similar Papers

Cite this paper

@article{madaan2026learning,
  title  = {Learning Performance-Improving Code Edits},
  author = {Aman Madaan and Alexander Shypula and Uri Alon and Milad Hashemi and Parthasarathy Ranganathan and Yiming Yang and Graham Neubig and A. Yazdanbakhsh},
  year   = {2026},
  eprint = {2302.07867},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/pdf/2302.07867},
  journal = {ICLR 2023 2023}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2302.07867.svg)](https://codeofpaper.com/paper/2302.07867)

Discussion