Note: information in this Chapter is applicable only to the Enterprise and Embedded Editions of Excelsior JET.
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:
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).
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 jet.jprof.name.
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.
As of version 15.3, PGO has the following limitations:
These limitations will be removed in future releases of Excelsior JET.