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.

Figure 4. Profile-directed feedback 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.

  1. Compile your application using -qpdf1 and -qshowpdf.
  2. Run your application using one or more characteristic data sets.
  3. 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:

  1. Compile your application with -qpdf1.
  2. Run your application with one or more characteristic data sets. This produces a PDF file in the current directory.
  3. 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.
  4. 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
  5. 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.