NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Profile Guided Optimization without Profiles: A Machine Learning Approach

Nadav Rotem, Chris CumminsarXiv 2021

Abstract

Profile Guided Optimization (PGO) significantly enhances software performance by utilizing runtime data to inform compiler decisions. However, the logistical complexity of profile collection often precludes its use in general-purpose software development. This paper presents a machine learning-based alternative that replaces static compiler heuristics with Gradient Boosted Trees (XGBoost) trained on millions of branches. The resulting model provides a "zero-cost" performance boost, achieving a geometric mean speedup of 1.6% across diverse workloads, with gains as high as 16% for Python, while maintaining negligible impact on compilation time.

Introduction

In high-performance computing, PGO serves as a critical optimization technique. By executing a program with representative data, compilers can identify "hot" code paths and optimize them accordingly. Despite its benefits, PGO is rarely used in general-purpose software due to the "PGO tax"—the overhead of maintaining complex build pipelines and representative datasets.

In the absence of PGO, compilers rely on static Branch Probability Info (BPI). BPI consists of hundreds of hand-written heuristics developed over decades. While useful, these rules are often imprecise and struggle to adapt to the complexities of modern code patterns. This research proposes replacing these aging heuristics with a statistical model that predicts branch probabilities using static features available at compile time.

Methodology

The authors developed a "Prediction Guided Optimization" workflow that transitions from human-engineered rules to a data-driven approach.

Workflow and Training

The process begins with offline training using a massive corpus of open-source programs. By applying a standard PGO workflow to these projects, the researchers generated a "ground truth" dataset where each branch is labeled with its observed runtime probability.

The Prediction Guided Optimization workflow: Offline training on PGO-labeled data followed by online deployment of a trained model within the compiler.

The model utilizes 54 static features, including loop depth, instruction counts per block, and control flow indicators (e.g., exception handling). XGBoost was selected as the modeling framework due to its speed, low memory footprint, and structural similarity to existing compiler logic, which aids in interpretability and debugging.

Integration

To ensure zero-cost deployment, the trained trees are converted into a compact C++ representation—a 2MB data table and a lightweight interpreter—embedded directly into the LLVM compiler. This allows the compiler to perform inference without external ML library dependencies.

Evaluation and Results

The model was evaluated on a diverse set of applications, including sqlite, python, z3, and the llvm-test-suite.

Accuracy and Performance

The model classifies branch probabilities into 11 discrete bins (ranging from 0.0 to 1.0). It achieved a classification accuracy of 75%, demonstrating a significant improvement over traditional heuristics.

Confusion matrix showing the model's performance in classifying branch probabilities into 11 discrete bins.

Across ten major workloads, the approach yielded a geometric mean speedup of 1.6%. Notable outliers include Python, which saw a 16% performance increase, and Lua, which improved by 7%. Crucially, the inference engine is highly efficient, processing up to 1.6 million requests per second, ensuring that compilation times remain unaffected.

Discussion and Key Insights

A primary insight of this work is the effectiveness of ML as a direct replacement for specific compiler components. Unlike human-written rules that often rely on "round" probability estimates (e.g., 80/20 splits), the ML model identifies precise, non-obvious thresholds tailored to modern coding patterns. Furthermore, the use of decision trees maintains transparency, allowing compiler engineers to inspect and understand the model's decision-making process.

Limitations and Future Work

Despite broad success, the model is not a universal solution; for instance, bzip2 experienced a 7% performance regression, indicating that static features may not capture all runtime nuances. Future research could explore continuous regression models instead of discrete bins and apply similar data-driven techniques to other compiler optimizations such as function inlining or register allocation.

Conclusion

By automating the generation of compiler heuristics through machine learning, this approach provides the benefits of PGO without its operational burdens. The integration of pre-trained models into the compiler toolchain represents a significant step toward more intelligent, self-optimizing software infrastructure.

Summary updated

BibTeX
@misc{rotem2021profile,
  author = {Nadav Rotem and Chris Cummins},
  title = {{Profile Guided Optimization without Profiles: A Machine Learning Approach}},
  year = {2021},
  eprint = {2112.14679},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2112.14679},
}
Figure