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.
翻译:Moore Law 的衰减使技术产业的重点转向了持续绩效增益的替代方法。 虽然优化编译者是帮助提高程序效率的一个标准工具, 但程序员在编译和重构功能特点更好的代码方面继续承担着很大的责任。 在本文中, 我们调查大型语言模型(LLIMs) 的能力, 以建议功能正确、 性能改进代码编辑。 我们假设语言模型可以建议这类编辑方式, 仅对静态分析来说是不切实际的。 我们通过整理绩效改进编辑的大型数据集( PIE ), PIE 是一个标准工具, 帮助提高程序的效率, 在编译程序初始、 较慢的版本和迭代修改程序方面, 我们用PIE 来评估和微调的多变异模式, 10亿级的变异模式, 更小的变异模式。 此外, 我们从 PIEE 到快速的 OODI 的 CODEX, 使用微缩略的 CODUD, 和 CIE 快速化程序, 生成了更具有挑战性的业绩, 25 GEN 的 CIEODOD,,, 的CODODD, 和我们发现我们用新的系统可以比 CIERDODODODDDDD 更快的系统, 更 更 更 更 更新的C- CODODD 的系统, 更新了 和 25 更新的系统。