Optimizing Code Runtime Performance Through Context-Aware Retrieval-Augmented Generation
Optimizing software performance through automated code refinement offers a promising avenue for enhancing execution speed and efficiency. Despite recent advancements in LLMs, a significant gap remains in their ability to perform indepth program analysis. This study introduces AutoPatch, an in-context learning approach designed to bridge this gap by enabling LLMs to automatically generate optimized code. Inspired by how programmers learn and apply knowledge to optimize software, AutoPatch incorporates three key components: (1) an analogy-driven framework to align LLM optimization with human cognitive processes, (2) a unified approach that integrates historical code examples and CFG analysis for context-aware learning, and (3) an automated pipeline for generating optimized code through in-context prompting. Experimental results demonstrate that AutoPatch achieves a <tex xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">$\mathbf{7. 3 \%}$</tex> improvement in execution efficiency over GPT-4o across common generated executable code, highlighting its potential to advance automated program runtime optimization.
Authors
- Kevin Leach (ORCID: https://orcid.org/0000-0002-4001-3442)
- Yu Huang (ORCID: https://orcid.org/0000-0003-4535-4331)
- Maya Acharya (ORCID: https://orcid.org/0009-0001-3378-7749)
- Yifan Zhang (ORCID: https://orcid.org/0000-0003-1289-2192)
Institutions
- Vanderbilt University (US)
Publication Details
- Published
- 2025-04-27
- DOI
- https://doi.org/10.1109/icpc66645.2025.00028
- Primary Topic
- Distributed and Parallel Computing Systems
- Type
- article
- Field-Weighted Citation Impact
- 0.00