arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2510.10517cs.PLcs.AIcs.SE
收藏

ECO:通过面向性能的提示增强代码LLM的代码优化

ECO: Enhanced Code Optimization via Performance-Aware Prompting for Code-LLMs

Yonsei University(延世大学);Sungkyunkwan University(成均馆大学)

Su-Hyeon Kim, Joonghyuk Hahn, Sooyoung Cha, Yo-Sub Han

AI总结:

提出面向性能的提示框架ECO,通过提取运行时优化指令并结合符号顾问的瓶颈诊断,为代码LLM提供模型无关的优化指导,显著提升代码生成效率,实现高达7.81倍加速。

摘要:

代码运行时优化——即将给定代码重写为更快代码的任务——仍然具有挑战性,因为它需要对涉及算法和结构选择的性能权衡进行推理。最近的方法采用代码LLM,并提供慢-快代码对作为优化指导,但这种基于对的方法掩盖了性能提升的因果因素,通常导致表面的模式模仿,而非真正的性能推理。我们引入了ECO,一个面向性能的代码优化提示框架。ECO首先从参考慢-快代码对中提取运行时优化指令(ROIs);每个ROI描述了低效的根本原因以及驱动性能提升的原理。对于给定的输入代码,ECO并行采用(i)一个符号顾问来生成针对该代码的瓶颈诊断,以及(ii)一个ROI检索器来返回相关的ROIs。这两个输出随后被组合成一个面向性能的提示,为代码LLM提供可操作的指导。ECO的提示与模型无关,无需微调,可以轻松地预置到任何代码LLM提示之前。我们的实证研究表明,ECO提示显著提升了代码LLM生成高效代码的能力,实现了高达7.81倍的加速,同时将正确性损失降至最低。

英文摘要:

Code runtime optimization-the task of rewriting a given code to a faster one-remains challenging, as it requires reasoning about performance trade-offs involving algorithmic and structural choices. Recent approaches employ code-LLMs with slow-fast code pairs provided as optimization guidance, but such pair-based methods obscure the causal factors of performance gains and often lead to superficial pattern imitation rather than genuine performance reasoning. We introduce ECO, a performance-aware prompting framework for code optimization. ECO first distills runtime optimization instructions (ROIs) from reference slow-fast code pairs; Each ROI describes root causes of inefficiency and the rationales that drive performance improvements. For a given input code, ECO in parallel employs (i) a symbolic advisor to produce a bottleneck diagnosis tailored to the code, and (ii) an ROI retriever to return related ROIs. These two outputs are then composed into a performance-aware prompt, providing actionable guidance for code-LLMs. ECO's prompts are model-agnostic, require no fine-tuning, and can be easily prepended to any code-LLM prompt. Our empirical studies highlight that ECO prompting significantly improves code-LLMs' ability to generate efficient code, achieving speedups of up to 7.81x while minimizing correctness loss.

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

↑