用性能分析器指导迭代优化,让代码代理更精准提升运行速度。
PerfAgent: Profiler-Guided Iterative Refinement for Repository-Level Code Optimization
- 引入性能分析器反馈,引导代理发现真实瓶颈
- 在GSO和SWE-fficiency-Lite上专家级优化成功率翻倍
- 适合需要高效代码优化的开发者和自动化测试团队
大语言模型代理在正确性导向的仓库级任务中表现良好,但在代码优化方面仍面临挑战:需在保持行为一致的前提下提升运行效率。仅通过测试不足够,补丁必须同时保证行为正确、实现优化并接近专家级提速效果。现有代理常忽略抽象层与原生扩展背后的性能瓶颈,优化浅显且测试不足,可能隐性破坏边界情况。我们提出PerfAgent,一种基于性能分析器的闭环验证工作流,使通用编码代理获得关键反馈,精准定位热点,持续优化至首个通过补丁之后,并以分析证据替代单纯计时判断优化优先级。在GSO和SWE-fficiency-Lite两个挑战性优化基准上,PerfAgent将专家匹配率从OpenHands(GPT-5.1)的19.6%提升至39.2%(GSO),从26%提升至74%(SWE-fficiency-Lite),且优于五次采样最优基线,成本更低,证明增益来自更优反馈而非额外采样。
原文摘要 · Abstract (English)
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.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。