Table of Contents
Fetching ...

PEACE: Towards Efficient Project-Level Efficiency Optimization via Hybrid Code Editing

Xiaoxue Ren, Jun Wan, Yun Peng, Zhongxin Liu, Ming Liang, Dajun Chen, Wei Jiang, Yong Li

TL;DR

This paper tackles the challenge of optimizing code efficiency at the project level, where inter-function interactions complicate single-function edits. It introduces Peace, a three-phase hybrid framework that builds dependency-aware optimization sequences, identifies valid historical edits, and iteratively refines edits with a fine-tuned efficiency optimizer guided by internal and external high-performance code. A new benchmark, PeacExec, containing 146 tasks from 47 GitHub Python projects, enables rigorous evaluation; Peace achieves 69.2% pass@1, +46.9% opt rate, and 0.840 speedup, surpassing state-of-the-art baselines. The work demonstrates that combining LLM-based project reasoning with a cost-effective fine-tuned optimizer yields robust, scalable, project-wide performance improvements, with implications for real-world software maintenance and optimization workflows.

Abstract

Large Language Models (LLMs) have demonstrated significant capability in code generation, but their potential in code efficiency optimization remains underexplored. Previous LLM-based code efficiency optimization approaches exclusively focus on function-level optimization and overlook interaction between functions, failing to generalize to real-world development scenarios. Code editing techniques show great potential for conducting project-level optimization, yet they face challenges associated with invalid edits and suboptimal internal functions. To address these gaps, we propose Peace, a novel hybrid framework for Project-level code Efficiency optimization through Automatic Code Editing, which also ensures the overall correctness and integrity of the project. Peace integrates three key phases: dependency-aware optimizing function sequence construction, valid associated edits identification, and efficiency optimization editing iteration. To rigorously evaluate the effectiveness of Peace, we construct PeacExec, the first benchmark comprising 146 real-world optimization tasks from 47 high-impact GitHub Python projects, along with highly qualified test cases and executable environments. Extensive experiments demonstrate Peace's superiority over the state-of-the-art baselines, achieving a 69.2% correctness rate (pass@1), +46.9% opt rate, and 0.840 speedup in execution efficiency. Notably, our Peace outperforms all baselines by significant margins, particularly in complex optimization tasks with multiple functions. Moreover, extensive experiments are also conducted to validate the contributions of each component in Peace, as well as the rationale and effectiveness of our hybrid framework design.

PEACE: Towards Efficient Project-Level Efficiency Optimization via Hybrid Code Editing

TL;DR

This paper tackles the challenge of optimizing code efficiency at the project level, where inter-function interactions complicate single-function edits. It introduces Peace, a three-phase hybrid framework that builds dependency-aware optimization sequences, identifies valid historical edits, and iteratively refines edits with a fine-tuned efficiency optimizer guided by internal and external high-performance code. A new benchmark, PeacExec, containing 146 tasks from 47 GitHub Python projects, enables rigorous evaluation; Peace achieves 69.2% pass@1, +46.9% opt rate, and 0.840 speedup, surpassing state-of-the-art baselines. The work demonstrates that combining LLM-based project reasoning with a cost-effective fine-tuned optimizer yields robust, scalable, project-wide performance improvements, with implications for real-world software maintenance and optimization workflows.

Abstract

Large Language Models (LLMs) have demonstrated significant capability in code generation, but their potential in code efficiency optimization remains underexplored. Previous LLM-based code efficiency optimization approaches exclusively focus on function-level optimization and overlook interaction between functions, failing to generalize to real-world development scenarios. Code editing techniques show great potential for conducting project-level optimization, yet they face challenges associated with invalid edits and suboptimal internal functions. To address these gaps, we propose Peace, a novel hybrid framework for Project-level code Efficiency optimization through Automatic Code Editing, which also ensures the overall correctness and integrity of the project. Peace integrates three key phases: dependency-aware optimizing function sequence construction, valid associated edits identification, and efficiency optimization editing iteration. To rigorously evaluate the effectiveness of Peace, we construct PeacExec, the first benchmark comprising 146 real-world optimization tasks from 47 high-impact GitHub Python projects, along with highly qualified test cases and executable environments. Extensive experiments demonstrate Peace's superiority over the state-of-the-art baselines, achieving a 69.2% correctness rate (pass@1), +46.9% opt rate, and 0.840 speedup in execution efficiency. Notably, our Peace outperforms all baselines by significant margins, particularly in complex optimization tasks with multiple functions. Moreover, extensive experiments are also conducted to validate the contributions of each component in Peace, as well as the rationale and effectiveness of our hybrid framework design.
Paper Structure (43 sections, 7 figures, 3 tables)

This paper contains 43 sections, 7 figures, 3 tables.

Figures (7)

  • Figure 1: Motivating Example of Valid Associated Edits
  • Figure 2: Motivating Example of Optimization Knowledge
  • Figure 3: The Overall Framework of Peace
  • Figure 4: Agent Pipeline for Identifying Valid Associate Edits
  • Figure 5: Prompts for Fine-tuning Code Efficiency Optimizer
  • ...and 2 more figures