PerfAgent: Profiler-Guided Iterative Refinement for Repository-Level Code Optimization
Ryan Deng, Yuanzhe Liu, Bastian Lipka, Yao Ma, Xuhao Chen, Tim Kaler, Jatin Ganhotra
Abstract
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.
Create a lesson
Related papers
RepoReasoner: Evaluating Repository-Level Code Reasoning Ability of Long-Context Language Models
Shared title terminology · Yanlin Wang, Suiquan Wang, Yanli Wang et al.
RuBench: A Repository-Level Agentic Coding Benchmark with Natively Authored Russian Task Specifications
Shared title terminology · Evgeny Shilov
Dependency-Guided Code Generation: Structured Matrix Decomposition and Consistency-Guided Refinement
Shared title terminology · Mingqiao Mo, Yangchen Zeng, Zikai Xiao et al.
Multi-level Code Optimization via Mixture of Prompts
Shared title terminology · Yun Peng, Jun Wan, Jiakun Liu et al.
Multi-Source and Cross-Scenario Strategy-Guided Code Optimization
Shared title terminology · Yuwei Zhao, Qianyu Xiao, Ye Cui et al.
What Should an LLM Know? Knowledge-Guided Warm Starts for Software Optimization
Shared title terminology · Srinath Srinivasan, Tim Menzies