Super Prev Next

Profile-Guided Optimization

Note: information in this Chapter is applicable only to the Enterprise and Embedded Editions of Excelsior JET.

Super Prev Next


It is widely known that OpenJDK HotSpot and other advanced JIT compilers collect execution profile data and use them to optimize code more effectively. A lesser known fact is that all popular C++ compilers, free and commercial, implement profile-guided optimization (PGO) as well. The main difference is that the profile data should be collected separately by running the application and then fed to the compiler.

Starting from version 12, Excelsior JET, Enterprise Edition and Excelsior JET Embedded will offer PGO as an option. If you wish to use PGO, two extra steps are added to the build process:

  1. build the project normally, i.e. without PGO
  2. new step: run the resulting binary under typical load with profiling enabled
  3. new step: rebuild the project with PGO enabled
  4. proceed as before (test, package, etc.)

The good news is that the overheads are less significant than you might expect:

In our tests, application performance improvements delivered by PGO can be quite significant, especially when combined with the Global Optimizer (see Chapter Global Optimizer).

Super Prev Next

Collecting profile

Set the system property jet.profiler, launch your JET-compiled application and run it through some performance-challenging scenarios, either manually or by supplying the necessary input data.

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

On application exit, AppName.jprof file containing the collected profile data will be created in the current directory.

If you wish to set a non-default name for the file, specify it with the system property

Super Prev Next

Enabling PGO

For projects created with Excelsior JET prior to version 12:

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


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 collected on the previous step 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.

Instead of explicitly specifying a .jprof file in each project, you can use profile repository, a directory containing profile files for different applications. For that, replace




and copy all collected profiles to that directory. The compiler will automatically select the necessary .jprof file by the name of executable or DLL being compiled. /More precisely, the value of the OUTPUTNAME equation will be used to match the name./

Note: Your application may spend a lot of CPU time in the code of Java Platform API classes, such as standard collections. To further improve performance, add the platform classes to the scope of PGO by enabling the Global Optimizer (see Enabling the Global Optimizer). There is no need to re-collect the execution profile in this case as it already contains the necessary information for the platform classes.

Super Prev Next

Known limitations

As of version 15.3, PGO has the following limitations:

  1. if AppName.jprof already exists, it is overwritten without a warning as 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
  3. the executables that were built with PGO enabled cannot themselves be run in the profiling mode
  4. 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 allows you to use the same project files for 32- and 64-bit builds, but only the latter would benefit from PGO.

These limitations will be removed in future releases of Excelsior JET.