Profile Guided Optimization
Profile-Guided Optimization (PGO) is an optimization technique where a performance profile is fed to the compiler to provide optimization information that is not directly evident from the source code, such as branching patterns which are the result of patterns in the input data.
PGO involves these steps:
- A version of the program is built with profiling enabled.
- A representative test run is performed, and profile data is collected.
- The program is re-compiled, with the profile data provided as one of the inputs to the compiler.
Both GCC and LLVM have PGO features. Note that the profiling options, instrumentation, and profile data is not the same as that used with other tools such as gprof.