Benefits of profile-directed feedback (PDF)
Beginning with -O4, compiling with -qpdf to trigger profile-directed feedback is a viable option to
increase performance in many applications. Profile-directed feedback is a
two-stage compilation process that provides the compiler with the execution
path characteristic of your application's typical behavior after a sample
execution. The optimizer uses that information to focus optimization trade-offs
in favour of code that executes more frequently.
- PDF at Stage 1: Compiling with -qpdf1 instruments your
code with calls to the PDF runtime library that are linked with your application.
After compilation, execute your application with typical input data. You can
execute your application with as many data sets as you have, each run records
PDF information in data files. Avoid using atypical data which can skew the
analysis to favour infrequently executed code paths.
- PDF at Stage 2: After collecting PDF information, recompiling
or relinking your application using -pdf2 allows the compiler to
read information from the PDF data files and makes that information available
to the optimizer. Using this data, the optimizer can better direct transformations
to facilitate more intense performance gains.
Figure 4. Profile-directed feedback

PDF walkthrough
The following steps are a guide through PDF optimization.
These steps also include the use of utilities designed to enhance the PDF
process. While PDF is recommended at -O4 and higher, you can specify -qpdf as early in the optimization process as -O2 but will not
necessarily achieve optimal results.
- Compile your application using -qpdf1 and -qshowpdf.
- Run your application using one or more characteristic data sets.
- Use the showpdf utility if you wish to view the information in
the PDF file.
To exert more control over the PDF process, use the following steps:
- Compile your application with -qpdf1.
- Run your application with one or more characteristic data sets. This produces
a PDF file in the current directory.
- Copy your application to another directory and run it again. This produces
a PDF file in the second directory. You can repeat this step multiple times.
- Use the mergepdf utility to combine all PDF files into a single
file. For example, if you produce three PDF files that represent usage patterns
that will occur 53%, 32%, and 15% of the time respectively, you can use the
following syntax:
mergepdf -r 53 path1 -r 32 path2 -r 15 path3
- Compile the application with -qpdf2.
Alternatively, you can use -qpdf2 to link the object
files the -qpdf1 pass creates without recompiling your source on
the -qpdf2 pass. This alternate approach can save considerable time
and help tune large applications for optimization. You can create and test
different styles of PDF optimized binaries by specifying different options
on the -qpdf2 pass.
To erase PDF information in a directory, use the cleanpdf or resetpdf utility.