arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2512.22827cs.SEcs.AI
收藏

FasterPy:基于大语言模型的代码执行效率优化框架

FasterPy: An LLM-based Code Execution Efficiency Optimization Framework

School of Computer Science, Wuhan University(武汉大学计算机学院);School of Computer Science, Carnegie Mellon University(卡内基梅隆大学计算机学院);School of Mathematical and Computational Sciences, Massey University(梅西大学数学与计算科学学院);School of Computer Science, Central China Normal University(中央中国师范大学计算机学院);School of Computer Science, Nanjing University of Science and Technology(南京理工大学计算机学院);School of Computing Technologies, RMIT University(皇家墨尔本理工大学计算技术学院)

Yue Wu, Minghao Han, Ruiyin Li, Peng Liang, Amjed Tahir, Zengyang Li, Qiong Feng, Mojtaba Shahin

AI总结:

提出FasterPy框架,结合检索增强生成(RAG)和低秩适应(LoRA)技术,利用大语言模型自动优化Python代码执行效率,在PIE基准上超越现有方法。

摘要:

代码常常存在性能缺陷,这促使了对代码优化的研究和实践。传统的基于规则的方法依赖于为特定性能缺陷(如冗余循环、重复计算)手动设计和维护规则,因此劳动密集且适用性有限。近年来,基于机器学习和深度学习的方法通过学习来自标注代码语料库和性能测量的优化启发式,成为有前景的替代方案。然而,这些方法通常依赖于特定的程序表示和精心制作的训练数据集,使得开发成本高且难以扩展。随着大语言模型(LLMs)的蓬勃发展,它们在代码生成方面的卓越能力为自动化代码优化开辟了新途径。在这项工作中,我们提出了FasterPy,一个低成本且高效的框架,它使LLMs适应于优化Python代码的执行效率。FasterPy结合了检索增强生成(RAG)(由从现有性能改进代码对和相应性能测量构建的知识库支持)与低秩适应(LoRA),以增强代码优化性能。我们在Performance Improving Code Edits(PIE)基准上的实验结果表明,我们的方法在多个指标上优于现有模型。FasterPy工具和实验结果可在此https URL获取。

英文摘要:

Code often suffers from performance bugs. These bugs necessitate the research and practice of code optimization. Traditional rule-based methods rely on manually designing and maintaining rules for specific performance bugs (e.g., redundant loops, repeated computations), making them laborintensive and limited in applicability. In recent years, machine learning and deep learning-based methods have emerged as promising alternatives by learning optimization heuristics from annotated code corpora and performance measurements. However, these approaches usually depend on specific program representations and meticulously crafted training datasets, making them costly to develop and difficult to scale. With the booming of Large Language Models (LLMs), their remarkable capabilities in code generation have opened new avenues for automated code optimization. In this work, we proposed FasterPy, a low-cost and efficient framework that adapts LLMs to optimize the execution efficiency of Python code. FasterPy combines Retrieval-Augmented Generation (RAG), supported by a knowledge base constructed from existing performance-improving code pairs and corresponding performance measurements, with Low-Rank Adaptation (LoRA) to enhance code optimization performance. Our experimental results on the Performance-Improving Code Edits (PIE) benchmark demonstrate the effectiveness of our method across multiple metrics. The FasterPy tool and the experimental results are available at https://github.com/WuYue22/fasterpy.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑