Feedback-Directed Optimisation
   HOME

TheInfoList



OR:

Profile-guided optimization (PGO, sometimes pronounced as ''pogo''), also known as profile-directed feedback (PDF), and feedback-directed optimization (FDO) is a
compiler optimization In computing, an optimizing compiler is a compiler that tries to minimize or maximize some attributes of an executable computer program. Common requirements are to minimize a program's execution time, memory footprint, storage size, and power con ...
technique in computer programming that uses profiling to improve program runtime performance.


Method

Optimization techniques based on static program analysis of the source code consider code performance improvements without actually executing the program. No dynamic program analysis is performed. The analysis may even consider code within loops including the number of times the loop will execute, for example in loop unrolling. In the absence of all the run time information, static program analysis can not take into account how frequently that code section is actually executed. The first high-level compiler, introduced as the Fortran Automatic Coding System in 1957, broke the code into blocks and devised a table of the frequency each block is executed via a simulated execution of the code in a Monte Carlo fashion in which the outcome of conditional transfers (as via IF-type statements) is determined by a random number generator suitably weighted by whatever FREQUENCY statements were provided by the programmer. Rather than programmer-supplied frequency information, profile-guided optimization uses the results of profiling test runs of the instrumented program to optimize the final generated code. The compiler accesses profile data from a sample run of the program across a representative input set. The results indicate which areas of the program are executed more frequently, and which areas are executed less frequently. All optimizations benefit from profile-guided feedback because they are less reliant on heuristics when making compilation decisions. The caveat, however, is that the sample of data fed to the program during the profiling stage must be statistically representative of the typical usage scenarios; otherwise, profile-guided feedback has the potential to harm the overall performance of the final build instead of improving it. Just-in-time compilation can make use of runtime information to dynamically recompile parts of the executed code to generate a more efficient native code. If the dynamic profile changes during execution, it can deoptimize the previous native code, and generate a new code optimized with the information from the new profile.


Adoption

There is support for building Firefox using PGO.Building with Profile-Guided Optimization
mozilla.org, 13 August 2013
Even though PGO is effective, it has not been widely adopted by software projects, due to its tedious dual-compilation model. It is also possible to perform PGO without instrumentation by collecting a profile using
hardware performance counters In computers, hardware performance counters (HPC), or hardware counters are a set of special-purpose registers built into modern microprocessors to store the counts of hardware-related activities within computer systems. Advanced users often rely on ...
.Dehao Chen (2010),
Taming hardware event samples for fdo compilation
, ''Proceedings of the 8th annual IEEE/ACM international symposium on Code generation and optimization'', pp. 42–52.
This sampling-based approach has a much lower overhead and does not require a special compilation. The
HotSpot Hotspot, Hot Spot or Hot spot may refer to: Places * Hot Spot, Kentucky, a community in the United States Arts, entertainment, and media Fictional entities * Hot Spot (comics), a name for the DC Comics character Isaiah Crockett * Hot Spot (Tra ...
Java virtual machine A Java virtual machine (JVM) is a virtual machine that enables a computer to run Java programs as well as programs written in other languages that are also compiled to Java bytecode. The JVM is detailed by a specification that formally describes ...
(JVM) uses profile-guided optimization to dynamically generate native code. As a consequence, a software binary is optimized for the actual
load Load or LOAD may refer to: Aeronautics and transportation *Load factor (aeronautics), the ratio of the lift of an aircraft to its weight *Passenger load factor, the ratio of revenue passenger miles to available seat miles of a particular transpo ...
it is receiving. If the load changes, adaptive optimization can dynamically recompile the running software to optimize it for the new load. This means that all software executed on the HotSpot JVM effectively make use of profile-guided optimization. PGO has been adopted in the
Microsoft Windows Windows is a group of several proprietary graphical operating system families developed and marketed by Microsoft. Each family caters to a certain sector of the computing industry. For example, Windows NT for consumers, Windows Server for serv ...
version of
Google Chrome Google Chrome is a cross-platform web browser developed by Google. It was first released in 2008 for Microsoft Windows, built with free software components from Apple WebKit and Mozilla Firefox. Versions were later released for Linux, macOS ...
. PGO was enabled in the 64-bit edition of Chrome starting with version 53 and version 54 for the
32-bit In computer architecture, 32-bit computing refers to computer systems with a processor, memory, and other major system components that operate on data in 32-bit units. Compared to smaller bit widths, 32-bit computers can perform large calculation ...
edition. Google published a paper describing a system (AutoFDO) in use for using production profiles to guide builds resulting in up to a 10% performance improvement.


Implementations

Examples of compilers that implement PGO are: *
Intel C++ Compiler Intel oneAPI DPC++/C++ Compiler and Intel C++ Compiler Classic are Intel’s C, C++, SYCL, and Data Parallel C++ (DPC++) compilers for Intel processor-based systems, available for Windows, Linux, and macOS operating systems. Overview Intel o ...
and Fortran compilers * GNU Compiler Collection compilers *
Oracle Solaris Studio Oracle Developer Studio, formerly named Oracle Solaris Studio, Sun Studio, Sun WorkShop, Forte Developer, and SunPro Compilers, is Oracle Corporation's flagship software development product for the Solaris and Linux operating systems. It inclu ...
(formerly called Sun Studio) * Microsoft Visual C++ compiler * Clang * IBM XL C/C++ * GraalVM Enterprise Edition


See also

* Adaptive optimization * Dynamic dead code elimination * Global optimization *
Hot spot (computer programming) A hot spot in computer science is most usually defined as a region of a computer program where a high proportion of executed instructions occur or where most time is spent during the program's execution (not necessarily the same thing since some i ...
* Interprocedural optimization **
Link-time optimization Interprocedural optimization (IPO) is a collection of compiler techniques used in computer programming to improve performance in programs containing many frequently used functions of small or medium length. IPO differs from other compiler optimiz ...
(LTO) * Tracing just-in-time compilation


References

{{Compiler optimizations Compiler optimizations