US-20260126977-A1 - STATIC PROFILING WITH GRAPH NEURAL NETWORKS
Abstract
A method implements static profiling with graph neural networks. The method includes executing a block model with a control flow graph to generate a block vector corresponding to a block of the control flow graph of source code. The method further includes executing a graph neural network model with the control flow graph and the block vector to generate a graph vector. The method further includes executing a feed-forward neural network with the graph vector to generate a branch-frequency prediction. The method further includes incorporating the branch-frequency prediction into a code profile.
Inventors
- Vojin Jovanovic
- Milan CUGUROVIC
- Lazar MILIKIC
Assignees
- ORACLE INTERNATIONAL CORPORATION
Dates
- Publication Date
- 20260507
- Application Date
- 20241101
Claims (20)
- 1 . A method comprising: executing a block model with a control flow graph to generate a block vector corresponding to a block of the control flow graph of source code; executing a graph neural network model with the control flow graph and the block vector to generate a graph vector; executing a feed-forward neural network with the graph vector to generate a branch-frequency prediction; and incorporating the branch-frequency prediction into a code profile.
- 2 . The method of claim 1 , wherein the control flow graph is a caller control flow graph and wherein executing the graph neural network model comprises: inlining a callee control flow graph into the caller control flow graph.
- 3 . The method of claim 1 , further comprising: executing one or more of a parsing phase modifier and an inlining phase modifier with the code profile to generate modified code; and executing the modified code.
- 4 . The method of claim 1 , wherein executing the feed-forward neural network comprises: executing the feed-forward neural network with a plurality of graph vectors comprising the graph vector, a true branch graph vector, and a false branch graph vector.
- 5 . The method of claim 1 , wherein executing the block model further comprises: executing the block model with an intermediate representation and the control flow graph, wherein the control flow graph is generated with the intermediate representation.
- 6 . The method of claim 1 , wherein executing the block model further comprises: determining the block corresponds to conditional branching logic from the source code.
- 7 . The method of claim 1 , wherein incorporating the branch-frequency prediction comprises: incorporating a loop guard value instead of the branch-frequency prediction when the branch-frequency prediction satisfies a loop guard definition.
- 8 . The method of claim 1 , wherein incorporating the branch-frequency prediction comprises: incorporating an exit guard value instead of the branch-frequency prediction when the branch-frequency prediction satisfies an exit guard definition.
- 9 . The method of claim 1 , further comprising: training one or more of the graph neural network model and the feed-forward neural network by: executing a dynamic profiler to generate a branch frequency label; executing a loss function with a training branch-frequency prediction and the branch frequency label to generate a training update; and updating the one or more of the graph neural network model and the feed-forward neural network using the training update.
- 10 . The method of claim 1 , wherein executing the block model comprises: generating the block of the control flow graph from multiple nodes from an intermediate representation, wherein the intermediate representation represents the source code; generating multiple block features for the block from one or more of the control flow graph and the intermediate representation, wherein the block features comprise one or more of a node type feature, a code characteristic estimation feature, and a control flow characteristic feature; and aggregating the multiple block features to form the block vector.
- 11 . A system comprising: at least one processor; and an application that, when executing on the at least one processor, performs operations comprising: executing a block model with a control flow graph to generate a block vector corresponding to a block of the control flow graph of source code, executing a graph neural network model with the control flow graph and the block vector to generate a graph vector, executing a feed-forward neural network with the graph vector to generate a branch-frequency prediction, and incorporating the branch-frequency prediction into a code profile.
- 12 . The system of claim 11 , wherein the control flow graph is a caller control flow graph and wherein executing the graph neural network model comprises: inlining a callee control flow graph into the caller control flow graph.
- 13 . The system of claim 11 , wherein the application further performs operations comprising: executing one or more of a parsing phase modifier and an inlining phase modifier with the code profile to generate modified code; and executing the modified code.
- 14 . The system of claim 11 , wherein executing the feed-forward neural network comprises: executing the feed-forward neural network with a plurality of graph vectors comprising the graph vector, a true branch graph vector, and a false branch graph vector.
- 15 . The system of claim 11 , wherein executing the block model further comprises: executing the block model with an intermediate representation and the control flow graph, wherein the control flow graph is generated with the intermediate representation.
- 16 . The system of claim 11 , wherein executing the block model further comprises: determining the block corresponds to conditional branching logic from the source code.
- 17 . The system of claim 11 , wherein incorporating the branch-frequency prediction comprises: incorporating a loop guard value instead of the branch-frequency prediction when the branch-frequency prediction satisfies a loop guard definition.
- 18 . The system of claim 11 , wherein incorporating the branch-frequency prediction comprises: incorporating an exit guard value instead of the branch-frequency prediction when the branch-frequency prediction satisfies an exit guard definition.
- 19 . The system of claim 11 , wherein the application further performs operations comprising: training one or more of the graph neural network model and the feed-forward neural network by: executing a dynamic profiler to generate a branch frequency label; executing a loss function with a training branch-frequency prediction and the branch frequency label to generate a training update; and updating the one or more of the graph neural network model and the feed-forward neural network using the training update.
- 20 . A non-transitory computer readable medium comprising instructions executable by at least one processor to perform: executing a block model with a control flow graph to generate a block vector corresponding to a block of the control flow graph of source code; executing a graph neural network model with the control flow graph and the block vector to generate a graph vector; executing a feed-forward neural network with the graph vector to generate a branch-frequency prediction; and incorporating the branch-frequency prediction into a code profile.
Description
BACKGROUND Collecting accurate program profiles aids in optimizing program performance, as profile-guided optimization (PGO) leverages profiles to tailor compilation to runtime behavior. Compilers utilizing dynamic profiling, where profiles are collected by executing programs with representative inputs, may achieve performance gains that reduce runtimes of compiled code. Despite benefits from profile-guided optimization, complexity and resource demands of collecting dynamic profiles limit widespread adoption. Identifying representative inputs that reflect application use cases accurately is challenging, and collecting profiles based on inputs requires two compilations and a profile-collection run. As a result, large-scale software systems may not use profile-guided optimization in production due to difficulties obtaining program profiles. Static profiling techniques are an alternative to dynamic profiling challenges and may allow program profile prediction without runtime profiling and repeated compilation overhead. Static profiling methods may rely on heuristic-based approaches or machine learning (ML) models. Heuristic models, though efficient, depend on compiler-developer intuition and often fail to cover corner cases. Machine learning based models may capture complex program patterns and outperform heuristic models by delivering higher-quality profiles. Challenges with machine learning based static profilers include the inability to directly process and exploit an intermediate representation (IR) structure from a compiler and the inability to use calling context information effectively. For example, machine learning models may rely on handcrafted features to capture structural data from the intermediate representation of a program, which restricts the ability to fully represent the complexity of the intermediate representation. Additionally, machine learning models may make predictions based on individual function information while neglecting broader calling context. SUMMARY In general, in one or more aspects, the disclosure relates to a method implementing static profiling with graph neural networks. The method includes executing a block model with a control flow graph to generate a block vector corresponding to a block of the control flow graph of source code. The method further includes executing a graph neural network model with the control flow graph and the block vector to generate a graph vector. The method further includes executing a feed-forward neural network with the graph vector to generate a branch-frequency prediction. The method further includes incorporating the branch-frequency prediction into a code profile. In general, in one or more aspects, the disclosure relates to a system that includes at least one processor and an application that executes on the at least one processor. Executing the application performs executing a block model with a control flow graph to generate a block vector corresponding to a block of the control flow graph of source code. Executing the application further performs executing a graph neural network model with the control flow graph and the block vector to generate a graph vector. Executing the application further performs executing a feed-forward neural network with the graph vector to generate a branch-frequency prediction. Executing the application further performs incorporating the branch-frequency prediction into a code profile. In general, in one or more aspects, the disclosure relates to a non-transitory computer readable medium including instructions executable by at least one processor. Executing the instructions performs executing a block model with a control flow graph to generate a block vector corresponding to a block of the control flow graph of source code. Executing the instructions further performs executing a graph neural network model with the control flow graph and the block vector to generate a graph vector. Executing the instructions further performs executing a feed-forward neural network with the graph vector to generate a branch-frequency prediction. Executing the instructions further performs incorporating the branch-frequency prediction into a code profile. Other aspects of one or more embodiments may be apparent from the following description and the appended claims. BRIEF DESCRIPTION OF DRAWINGS FIG. 1 and FIG. 2 show diagrams in accordance with the disclosure. FIG. 3 shows a method in accordance with the disclosure. FIG. 4, FIG. 5, FIG. 6, and FIG. 7 show examples in accordance with the disclosure. FIG. 8A and FIG. 8B show computing systems in accordance with the disclosure. Similar elements in the various figures are denoted by similar names and reference numerals. The features and elements described in one figure may extend to similarly named features and elements in different figures. DETAILED DESCRIPTION One or more embodiments may address the challenges of machine learning based static profiles using a graph neural network