PerfAgent: Profiler-Guided Iterative Refinement for Repository-Level Code Optimization

📄 arXiv: 2607.19653v1 📥 PDF

作者: Ryan Deng, Yuanzhe Liu, Bastian Lipka, Yao Ma, Xuhao Chen, Tim Kaler, Jatin Ganhotra

分类: cs.SE, cs.AI

发布日期: 2026-07-22


💡 一句话要点

提出PerfAgent以解决代码优化中的性能瓶颈问题

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 代码优化 性能分析 验证反馈 大型语言模型 软件工程 自动化编程 智能助手

📋 核心要点

  1. 现有的代码优化方法常常无法有效识别隐藏在抽象层和本地扩展后的性能瓶颈,导致优化效果有限。
  2. PerfAgent采用分析器指导和验证者反馈的工作流程,帮助编码代理找到真实的热点并进行深入优化。
  3. 在GSO和SWE-fficiency-Lite基准测试中,PerfAgent显著提高了专家匹配补丁的生成率,验证了其有效性。

📝 摘要(中文)

大型语言模型(LLM)代理在以正确性为导向的代码库任务中表现良好,但在代码优化方面仍面临挑战。PerfAgent通过引入分析器指导和验证者反馈,帮助代理识别真实的性能瓶颈,超越初步的修复,显著提高了优化补丁的质量。在GSO和SWE-fficiency-Lite两个基准测试中,PerfAgent的专家匹配补丁率分别从19.6%提升至39.2%,从26%提升至74%。

🔬 方法详解

问题定义:本论文旨在解决现有代码优化方法在保持行为的同时提升运行时性能的挑战。现有方法往往在识别性能瓶颈和测试代码补丁方面存在不足,导致优化效果不理想。

核心思路:PerfAgent通过引入分析器指导和验证者反馈,帮助编码代理识别真实的性能热点,并在初步修复后进行更深入的优化。这样的设计能够确保优化不仅仅停留在表面,而是基于实际性能数据进行决策。

技术框架:PerfAgent的整体架构包括三个主要模块:性能分析模块、代码生成模块和验证反馈模块。性能分析模块负责识别代码中的热点,代码生成模块生成优化补丁,验证反馈模块则确保补丁在保持功能的同时提升性能。

关键创新:PerfAgent的主要创新在于结合了性能分析和验证反馈,使得编码代理能够在优化过程中获得更准确的指导。这与传统方法的单一测试或简单的性能评估形成鲜明对比。

关键设计:在设计中,PerfAgent使用了基于分析器的性能数据而非单纯的时间测量来指导优化决策。此外,针对不同的优化目标,设定了相应的损失函数和评估标准,以确保生成的补丁能够有效提升性能。

🖼️ 关键图片

fig_0
img_1
img_2

📊 实验亮点

在GSO和SWE-fficiency-Lite基准测试中,PerfAgent的专家匹配补丁率分别从19.6%提升至39.2%,从26%提升至74%。此外,PerfAgent在成本上也优于最佳的五次测试基线,表明其改进源于更好的反馈机制,而非额外的测试时间采样。

🎯 应用场景

PerfAgent的研究成果在软件工程、自动化代码优化和智能编程助手等领域具有广泛的应用潜力。通过提高代码优化的效率和准确性,PerfAgent能够帮助开发者更快地实现高性能代码,降低维护成本,提升软件质量。未来,该技术还可能扩展到其他编程语言和框架中,进一步推动智能编程的发展。

📄 摘要(原文)

Large language model (LLM) agents now perform well on correctness-oriented repository-level tasks, including SWE-Bench issue resolution and feature implementation in real codebases. However, they still struggle with repository-level code optimization, which requires preserving behavior while improving runtime performance. Passing tests is not enough in this setting; a patch must preserve behavior, implement code optimization, and approach expert speedups. Current agents often miss bottlenecks hidden behind abstraction layers and native extensions, stop after shallow speedups, or insufficiently test the code patches that thus may silently break edge cases. We present PerfAgent, a profiler-guided, verifier-in-the-loop workflow that gives an off-the-shelf coding agent the feedback needed to find real hotspots, improve beyond the first passing patch, and use profiler evidence rather than timing alone to decide what to optimize next. On two challenging optimization benchmarks, GSO and SWE-fficiency-Lite, PerfAgent more than doubles the rate of expert-matching patches over OpenHands with GPT-5.1, improving from 19.6% to 39.2% on GSO and from 26% to 74% on SWE-fficiency-Lite. It also surpasses an oracle best-of-five baseline at substantially lower cost, showing that the gains come from better feedback rather than additional test-time sampling.