Skip to main content
QUICK REVIEW

[Paper Review] Profile Guided Optimization without Profiles: A Machine Learning Approach

Nadav Rotem, Chris Cummins|arXiv (Cornell University)|Dec 24, 2021
Parallel Computing and Optimization TechniquesComputer Science6 citations
TL;DR

This paper presents a machine learning approach to predict branch probabilities in uninstrumented programs without requiring profile data, using gradient-boosted decision trees trained on static program features from a large corpus of instrumented binaries. The method integrates seamlessly into LLVM, replacing hand-crafted heuristics in BranchProbabilityInfo with a learned model that achieves significant performance gains with negligible compilation overhead.

ABSTRACT

Profile guided optimization is an effective technique for improving the optimization ability of compilers based on dynamic behavior, but collecting profile data is expensive, cumbersome, and requires regular updating to remain fresh. We present a novel statistical approach to inferring branch probabilities that improves the performance of programs that are compiled without profile guided optimizations. We perform offline training using information that is collected from a large corpus of binaries that have branch probabilities information. The learned model is used by the compiler to predict the branch probabilities of regular uninstrumented programs, which the compiler can then use to inform optimization decisions. We integrate our technique directly in LLVM, supplementing the existing human-engineered compiler heuristics. We evaluate our technique on a suite of benchmarks, demonstrating some gains over compiling without profile information. In deployment, our technique requires no profiling runs and has negligible effect on compilation time.

Motivation & Objective

  • To address the high cost and maintenance burden of collecting profile-guided optimization (PGO) data in production compilers.
  • To replace LLVM’s complex, hand-authored branch probability heuristics with a data-driven, learnable model.
  • To enable accurate branch probability prediction in uninstrumented programs using only static program features.
  • To develop a scalable, low-overhead solution that integrates directly into the LLVM compilation pipeline.
  • To demonstrate measurable performance improvements in real-world workloads without profiling or runtime instrumentation.

Proposed method

  • Offline training uses a large corpus of instrumented binaries to collect static features (e.g., block counts, loop depth, branch conditions) and corresponding ground-truth branch probabilities from PGO metadata.
  • A gradient-boosted decision tree model (using XGBoost) is trained to predict branch probabilities based on these static features, replacing LLVM’s hand-coded heuristics in the BranchProbabilityInfo pass.
  • The model is embedded as a new compiler pass in LLVM that annotates branch weights at compile time using only static analysis information.
  • Feature engineering extracts over 30 static program features per branch, including control flow relationships, instruction counts, and predicate types.
  • The system avoids deep neural networks for interpretability and efficiency, favoring lightweight, interpretable decision trees that are easier to debug and maintain.
  • The final model is deployed in production with zero profiling overhead and minimal impact on compilation time.

Experimental results

Research questions

  • RQ1Can a learned model accurately predict branch probabilities in uninstrumented programs using only static features?
  • RQ2Can a machine learning model outperform hand-crafted heuristics in LLVM’s BranchProbabilityInfo pass without requiring profile data?
  • RQ3What is the performance impact of integrating a learned model into the LLVM compilation pipeline?
  • RQ4How does the model’s accuracy compare to existing approaches like ESP or VESPA that also predict branch probabilities?
  • RQ5Can a single, unified model benefit multiple optimization passes by providing accurate branch weight metadata?

Key findings

  • The learned model achieves significant performance gains on several open-source benchmarks when compiling without profile data, demonstrating the effectiveness of static prediction.
  • The model integrates seamlessly into LLVM with negligible compilation time overhead and zero memory footprint beyond the model itself.
  • The approach replaces thousands of lines of hand-authored C++ heuristics in BPI with a compact, interpretable decision tree model.
  • The system achieves high accuracy in predicting branch probabilities by leveraging a large corpus of training data with deterministic ground-truth labels from PGO workflows.
  • The model generalizes well to unseen programs, enabling consistent optimization improvements across diverse workloads.
  • The technique outperforms prior approaches that rely on proxy metrics or reinforcement learning by using direct, noise-free ground-truth labels from profiling.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.