Profile-guided Optimizations Methodology

PGO works best for code with many frequently executed branches that are difficult to predict at compile time. An example is the code with intensive error-checking in which the error conditions are false most of the time. The "cold" error-handling code can be placed such that the branch is hardly ever mispredicted. Minimizing "cold" code interleaved into the "hot" code improves instruction cache behavior.

PGO Phases

The PGO methodology requires three phases:

1. Instrumentation compilation and linking with -prof_gen

2. Instrumented execution by running the executable

3. Feedback compilation with -prof_use

The flowcharts below illustrate this process for IA-32 compilation and Itanium(TM)-based compilation. A key factor in deciding whether you want to use PGO lies in knowing which sections of your code are the most heavily used. If the data set provided to your program is very consistent and it elicits a similar behavior on every execution, then PGO can probably help optimize your program execution. However, different data sets can elicit different algorithms to be called. This can cause the behavior of your program to vary from one execution to the next.

IA-32 Phases of Basic Profile-Guided Optimization


Phases of Basic Profile-Guided Optimization for Itanium(TM)-based applications