This topic describes the various compiler options available in Oracle JRockit and HotSpot to optimize compilation.
Unlike Oracle JRockit, HotSpot features a Java byte code interpreter in addition to two different Just In Time (JIT) compilers: client (also known as C1) and server (also known as C2).
This section provides details about the complier that you can use.
HotSpot VM defaults to interpreting Java byte code. It compiles (JIT compilation) methods that runtime profiling determines to be "hot", that is, the methods that are executed for a predetermined number of times. JIT compliers are either client or server compilers.
Client compiler: It compiles methods quickly but emits machine code that is less optimized than the server compiler. This complier is used for quick startup. Also, in this compiler, the smaller memory footprint is more important than steady-state performance.
Server compiler: The compiler often takes more time (and memory) to compile the same methods. However, it generates better optimized machine code than the code generated by the client compiler. It provides better runtime performance after the application reaches the steady state.
The tiered compilation enhances the server VM startup speed equivalent to the client VM speed by using client compiler as the first tier. A server VM uses the interpreter to collect the profiling information about the methods that is fed into the compiler. In the tiered scheme, in addition to the interpreter, the client compiler generates compiled versions of methods that collect profiling information about themselves. As the compiled code is substantially faster than the interpreter, the program executes with greater performance during this profiling phase. Often, a startup that is even faster than with the client VM can be achieved, because the final code produced by the server compiler is available during the early stages of application initialization. The tiered scheme can also achieve better peak performance than a regular server VM. This is because the faster profiling phase allows a longer period of profiling, which yields better optimization.
Tiered compilation is the default mode for the server VM. The 64-bit mode is supported. To enable tiered compilation manually, use the -XX:+TieredCompilation
flag. You can disable tiered compilation by using the -XX:-TieredCompilation
flag.
Oracle JRockit JVM compiles a Java method and generates the machine code for the first time it is invoked. This compiled code of frequently invoked methods is optimized in the background by an Optimizer thread. This code is different from the HotSpot where methods are interpreted first and compiled later, either by the client (fewer optimizations) or the server (more optimizations) compiler.
The following table lists some important Oracle JRockit and HotSpot compiler options:
Table 4-1 JIT Compiler Options
Oracle JRockit | HotSpot | Notes |
---|---|---|
|
As JIT compilation in HotSpot is considered analogous to optimization in Oracle JRockit (that is, both techniques are only used on methods that are determined by profiling to be hot), the HotSpot equivalent to Oracle JRockit's Like Oracle JRockit, HotSpot also offers ways to exclude methods from compilation or to disable specific optimizations on them. If there are any problems while optimizing the methods, then use The same compilation or optimization problems observed with the Oracle JRockit JVM for any specific methods are unlikely to happen with the HotSpot JVM. So, to begin with, it is best to remove these options while migrating to the HotSpot JVM. Equivalent HotSpot JVM options are:
|
Options |
|
There are no optimization threads in HotSpot JVM. The count of compiler threads that perform both the compilation and the optimizations can be set using:
|
Sets the number of compiler threads to use for compilation. By default, the number of threads is set to 2 for the server JVM, to 1 for the client JVM, and it scales to the number of cores if tiered compilation is used. |
|
|
Sets the maximum code cache size (in bytes) for JIT-compiled code. This option is equivalent to |
None |
|
Enables the use of tiered compilation. This option is enabled by default from JDK 8 and later versions. Only the Java HotSpot Server VM supports this option. |