Language Models for Code Optimization: Survey, Challenges and Future Directions

Jingzhi Gong, Vardan Voskanyan, Paul Brookes, Fan Wu, Wei Jie, Jie Xu, Rafail Giavrimis, Mike Basios, Leslie Kanthan, Zheng WangarXiv 2025 · DOI

Introduction

Code optimization is the critical process of transforming software to enhance performance—such as reducing execution time or memory footprint—while strictly maintaining functional correctness. Historically, this task has transitioned from manual expert tuning to automated compiler heuristics. While classical Machine Learning (ML) and Deep Learning (DL) have been applied to this domain, they often struggle with the intricate semantic structures inherent in source code.

The evolution of code optimization techniques from manual efforts to language model-based approaches.

The emergence of Large Language Models (LLMs) presents a paradigm shift, offering neural "optimizers" capable of reasoning about program logic. This paper provides the first systematic literature review (SLR) of LLMs applied specifically to code optimization, analyzing 53 primary studies to map the current landscape and identify remaining hurdles.

Methodology and Taxonomy

The authors followed established software engineering guidelines for their SLR, filtering thousands of candidates to select 53 core studies. These studies were categorized using a multi-dimensional taxonomy organized around four primary Research Questions (RQs).

Taxonomy of LM-based code optimization, detailing research questions and categorization of the surveyed literature.

The taxonomy examines:

  • Model Roles: Beyond direct optimization, LMs serve as generators, evaluators (predicting performance gains), and preprocessors (inferring types or explaining logic).
  • Techniques: Approaches include model-based fine-tuning, advanced prompt engineering (e.g., Chain-of-Thought), and problem reformulation (e.g., Reinforcement Learning).
  • Training Paradigms: The study compares the utility of massive general-purpose models (like GPT-4) against smaller, code-specialized architectures (like CodeLLaMA).

Data Landscape

A significant finding is the reliance on specific dataset classes. While competitive programming benchmarks (HumanEval, MBPP) are common, they often lack real-world complexity. Performance-specific benchmarks like PIE and EffiBench are emerging as foundational. However, a critical gap exists: 68% of studies utilize synthetic data, while only 9% evaluate on full-scale, industrial software projects.

Generalists vs. Specialists

Contrary to expectations, general-purpose models like GPT-4 are utilized more frequently (61 instances) than code-specialized models (43 instances). Their superior instruction-following and reasoning capabilities often outweigh the benefits of domain-specific pre-training.

Iterative Refinement

LLMs rarely achieve optimal results in a single pass. The most effective systems implement feedback loops where the model generates code, an external compiler or profiler executes it, and the resulting performance metrics are fed back to the model for iterative improvement.

The Language Bias

Current research is heavily skewed toward Python (81% of studies). This leaves a significant opportunity for cross-lingual optimization research—transferring performance patterns learned in low-level languages like C++ to higher-level languages.

Challenges and Future Directions

Despite the promise of LLMs, several barriers to production deployment remain:

  1. Reliability: The "hallucination" of incorrect code is unacceptable in mission-critical systems.
  2. Efficiency: The computational cost of running massive models can sometimes exceed the energy savings gained from the optimization itself.
  3. Multi-objective Optimization: Most current work focuses on a single metric (usually execution time), ignoring the trade-offs between speed, memory usage, and power consumption.

The authors advocate for "agentic" workflows, where LMs act as autonomous agents interacting with IDEs and profilers to verify their own suggestions, ensuring both performance gains and functional integrity.

Summary updated

Abstract

Language models (LMs) built upon deep neural networks (DNNs) have recently demonstrated breakthrough effectiveness in software engineering tasks such as code generation, completion, and repair. This has paved the way for the emergence of LM-based code optimization techniques, which are crucial for enhancing the performance of existing programs, such as accelerating program execution time. However, a comprehensive survey dedicated to this specific application has been lacking. To fill this gap, we present a systematic literature review of over 50 primary studies, identifying emerging trends and addressing 11 specialized questions. Our findings reveal five critical open challenges, such as balancing model complexity with practical usability, cross-language/performance generalizability, and building trust in AI-driven solutions. Furthermore, we provide eight future research directions to facilitate more efficient, robust, and reliable LM-based code optimization. Thereby, this study aims to provide actionable insights and foundational references for both researchers and practitioners in this rapidly evolving field.
BibTeX
@misc{gong2025language,
  author = {Jingzhi Gong and Vardan Voskanyan and Paul Brookes and Fan Wu and Wei Jie and Jie Xu and Rafail Giavrimis and Mike Basios and Leslie Kanthan and Zheng Wang},
  title = {{Language Models for Code Optimization: Survey, Challenges and Future Directions}},
  year = {2025},
  eprint = {2501.01277},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2501.01277},
}
Figure