Profile-Guided Optimization

Debunking yet another JIT myth.

Profile-Guided Optimization (PGO) is a new feature of Excelsior JET 12 that enables the AOT compiler to base many optimization decisions on an actual execution profile of the application being compiled, as opposed to heuristics and generic data.

Important For PGO to be effective, it is paramount that you collect a profile representative of the future behaviour of your application in a production environment.

As of version 12, profile-guided optimization is supported by the following products:

  • 64-bit Excelsior JET, Enterprise Edition for Windows, OS X, and Linux
  • 64-bit Excelsior JET Embedded for Windows and Linux
  • Excelsior JET Embedded for Linux/ARM

To find out whether PGO may considerably improve the performance of your application, do the following:

Step 1. Collect an execution profile

Launch your natively compiled application with the jet.profiler property set, and run it through some performance-challenging scenarios, either manually or by supplying the necessary input data.
How do I set system properties at application launch?

Setting System Properties - A Quick Refresher

The system property setting mechanism varies depending on application type and build settings.

Example 1 (single-app executable):

On Windows, use a .bat file:

rem profileMyApp.bat
set JETVMPROP=-Djet.profiler
MyApp.exe TonsOfInputData.txt

On macOS/Linux, use a shell script:

#!/bin/bash
export JETVMPROP=-Djet.profiler
./MyApp TonsOfInputData.txt

Example 2 (multi-app executable)

MyMultiApp -Djet.profiler MainClass42 TonsOfInputData.txt

For details, refer to the Excelsior JET User's Guide, Chapter "Runtime Considerations", section "Java System Properties".

Note: Applications run approximately 10% slower than usual when profiling is enabled.

On application exit, an AppName.jprof file will be created in the current directory.

Step 2. Enable PGO and re-build the project

For projects created with a prior version of Excelsior JET:

Add the following two options to your project file, or to the command line of the Excelsior JET AOT compiler (jc):

-pgo+
-jprofile=AppName.jprof

and re-build your project.

For new projects:

By default, the JET Control Panel adds the above settings to all newly created projects and creates an empty AppName.jprof file in the build directory. All you need to enable PGO is replace that empty file with the one created on Step 1 and re-build your project.

In most cases, this step takes much less time than a full build, as the compiler only needs to process a few classes selected by the PGO engine.

Step 3 (optional). Try applying PGO to platform classes as well

Your application may be spending a lot of CPU time in the code of Java Platform API classes, such as standard collections. Adding the platform classes to the scope of PGO could therefore improve the performance of your application further, and that improvement can be quite significant. Enabling the Global Optimizer will do exactly that.

You can enable the Global Optimizer on the Classes page of the JET Control Panel, or by adding the option -global+ to the project file or the jc command line.

Notice There is no need to re-collect the execution profile as it already contains the necessary information for the platform classes.

From version 12, the Global Optimizer is available for all target platforms supported by Excelsior JET.

Known Limitations

  1. If the file AppName.jprof already exists, it gets overwritten without a warning, and profile merging is not implemented yet. This means that an execution profile must be collected in a single session.
  2. You cannot supply more than one .jprof file to the compiler, because yes, profile merging is not implemented yet.
  3. The executables that were built with PGO enabled cannot themselves be run in the profiling mode.

The above limitations will be removed in the next major release of Excelsior JET.

  1. The 32-bit versions of Excelsior JET for Windows and Linux support profiling, but do not support PGO. More precisely, they recognize the -pgo+ option, but it has no effect. This enables you to use the same project files for 32- and 64-bit builds, but only the latter would benefit from PGO.

This limitation will not be removed in the next major release, as that requires more than one development cycle.