Table of Contents
Fetching ...

Phaedrus: Predicting Dynamic Application Behavior with Lightweight Generative Models and LLMs

Bodhisatwa Chatterjee, Neeraj Jadhav, Santosh Pande

TL;DR

Phaedrus tackles the challenge of input-dependent dynamic application behavior by pairing two complementary approaches: Dynamis, which uses compiler-assisted LLM reasoning to predict hot functions without execution for guiding LLVM PGO, and Morpheus, which generalizes Whole Program Path profiles through input-consistent compression and augmentation to train lightweight sequence models. The framework demonstrates that LLMs can be integrated with static compiler analysis to achieve accurate, input-specific optimization guidance, while Morpheus provides scalable generalization across unseen inputs via compressed WPP traces. Empirical results on SPEC CPU 2017 and real-world benchmarks show substantial WPP compression (up to $10^7\times$), broad hotspot coverage (85–99% of runtime), and meaningful code-size and performance improvements, even without running the target programs. Overall, Phaedrus offers a practical path to robust profile-guided optimization that scales beyond traditional profiling by leveraging both zero-profile reasoning and generalized dynamic traces.

Abstract

Application profiling is an indispensable technique for many software development tasks, such as code and memory layout optimizations, where optimization decisions are tailored to specific program profiles. Unfortunately, modern application codebases exhibit highly variant behavior across different inputs, creating challenges for conventional profiling approaches that rely on a single representative execution instance. In this paper, we propose \textbf{Phaedrus}, a new \textit{compiler-assisted deep learning framework} designed to predict dynamic program behaviors across varied execution instances, specifically focusing on dynamic function call prediction.Such predicted call sequences are then used for producing optimized code pertinent to a given input. Traditional profile-guided optimization methods struggle with the input-dependent variability of modern applications, where profiling on different inputs yields divergent application behaviors. To address this, Phaedrus proposes two new approaches: \textit{Application Behavior Synthesis}, a profile-less approach where Large Language Models (LLMs) directly infer dynamic functions based on source code \& static compiler analysis, bypassing the need for traditional profiling, and \textit{Application Profile Generalization}, which uses generative models trained on compressed and augmented \textit{Whole Program Path} (WPP) based function profiles to predict application behavior under unseen inputs. Our experiments show that \textit{Phaedrus} can achieve upto $10^7X$ reduction in WPP function profile sizes, can predict most frequently executed functions that cover upto 85-99\% of the execution time, along with an average of 13.19\% (upto 65\%) reduction in application binary size, and an average of 6.08\% (upto 20\%) performance improvement over the traditional profile-guided optimization, without any execution.

Phaedrus: Predicting Dynamic Application Behavior with Lightweight Generative Models and LLMs

TL;DR

Phaedrus tackles the challenge of input-dependent dynamic application behavior by pairing two complementary approaches: Dynamis, which uses compiler-assisted LLM reasoning to predict hot functions without execution for guiding LLVM PGO, and Morpheus, which generalizes Whole Program Path profiles through input-consistent compression and augmentation to train lightweight sequence models. The framework demonstrates that LLMs can be integrated with static compiler analysis to achieve accurate, input-specific optimization guidance, while Morpheus provides scalable generalization across unseen inputs via compressed WPP traces. Empirical results on SPEC CPU 2017 and real-world benchmarks show substantial WPP compression (up to ), broad hotspot coverage (85–99% of runtime), and meaningful code-size and performance improvements, even without running the target programs. Overall, Phaedrus offers a practical path to robust profile-guided optimization that scales beyond traditional profiling by leveraging both zero-profile reasoning and generalized dynamic traces.

Abstract

Application profiling is an indispensable technique for many software development tasks, such as code and memory layout optimizations, where optimization decisions are tailored to specific program profiles. Unfortunately, modern application codebases exhibit highly variant behavior across different inputs, creating challenges for conventional profiling approaches that rely on a single representative execution instance. In this paper, we propose \textbf{Phaedrus}, a new \textit{compiler-assisted deep learning framework} designed to predict dynamic program behaviors across varied execution instances, specifically focusing on dynamic function call prediction.Such predicted call sequences are then used for producing optimized code pertinent to a given input. Traditional profile-guided optimization methods struggle with the input-dependent variability of modern applications, where profiling on different inputs yields divergent application behaviors. To address this, Phaedrus proposes two new approaches: \textit{Application Behavior Synthesis}, a profile-less approach where Large Language Models (LLMs) directly infer dynamic functions based on source code \& static compiler analysis, bypassing the need for traditional profiling, and \textit{Application Profile Generalization}, which uses generative models trained on compressed and augmented \textit{Whole Program Path} (WPP) based function profiles to predict application behavior under unseen inputs. Our experiments show that \textit{Phaedrus} can achieve upto reduction in WPP function profile sizes, can predict most frequently executed functions that cover upto 85-99\% of the execution time, along with an average of 13.19\% (upto 65\%) reduction in application binary size, and an average of 6.08\% (upto 20\%) performance improvement over the traditional profile-guided optimization, without any execution.

Paper Structure

This paper contains 27 sections, 1 theorem, 3 equations, 20 figures.

Key Result

lemma 1

In the absence of inter-procedural branches, function calls that are control-dependent on the same branch, and are present on the path of same branch target, can be compressed into a single token.

Figures (20)

  • Figure 1: An example of unsuccessful dynamic program analysis with the LLM, given the source code and input files (520.omnetpp_r). The LLM is unable to pinpoint hot functions in the benchmark just by observing the source code & input files, and the output is quite unsatisfactory.
  • Figure 2: An example of successful dynamic program analysis with the LLM, given the source code (519.lbm_r) and input files. The LLM is successfully able to pinpoint hot functions in the benchmark for the particular input file, along with the exact number of function calls.
  • Figure 3: A simple outline of control-flow behaviour and function calls in 519.lbm_r (SPEC2k17). The WPP based function profile data on the small input is also depicted.
  • Figure 4: Morpheus Compilation Framework. The front-end of Morpheus is build as integrated set of LLVM compiler passes, while the back-end leverages deep learning framework Pytorch to data processing and training the generative model.
  • Figure 5: Dynamis: A compiler-assisted LLM framework for predicting dynamic application behavior without any execution. The front-end of Dynamis provides the supplemental compiler analysis required by LLMs to reason about input-specific hot functions, while the backend involves leveraging those predictions to perform optimized compilation using LLVM's profile-guided optimization (PGO) pipeline.
  • ...and 15 more figures

Theorems & Definitions (1)

  • lemma 1