Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What exactly does -XX:-TieredCompilation do?

Tags:

java

jvm

jit

Using java -XX:+PrintFlagsFinal I found the TieredCompilation flag, and I read about it a bit online.

Yet, I still don't know exactly what happens when setting it to false.

I know that the compilation system supports 5 execution levels, basically splitted into interpreter, C1 and C2:

  • level 0 - interpreter
  • level 1 - C1 with full optimization (no profiling)
  • level 2 - C1 with invocation and backedge counters
  • level 3 - C1 with full profiling (level 2 + MDO)
  • level 4 - C2

Source: http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/file/2b2511bd3cc8/src/share/vm/runtime/advancedThresholdPolicy.hpp#l34

Two questions:

(1) By setting -XX:-TieredCompilation, are some of this levels just disabled? If yes, which?

(2) Is there some flag to decide whether to disable C1 or C2, or to not compile at all?

like image 242
Markus Weninger Avatar asked Aug 02 '16 13:08

Markus Weninger


People also ask

What is tiered compilation in .NET core?

Tiered compilation transitions methods through two tiers: The first tier generates code more quickly (quick JIT) or loads pre-compiled code (ReadyToRun). The second tier generates optimized code in the background ("optimizing JIT").

What is tiered compilation?

Tiered Compilation allows the . NET runtime to substitute different assembly code method implementations for the same method during the lifetime of an application to achieve higher performance.


1 Answers

-XX:-TieredCompilation disables intermediate compilation tiers (1, 2, 3), so that a method is either interpreted or compiled at the maximum optimization level (C2).

As a side effect TieredCompilation flag also changes the number of compiler threads, the compilation policy and the default code cache size. Note that with TieredCompilation disabled

  • there will be less compiler threads;
  • simple compilation policy (based on method invocation and backedge counters) will be chosen instead of advanced compilation policy;
  • default reserved code cache size will be 5 times smaller.

To disable C2 compiler and to leave only C1 with no extra overhead, set -XX:TieredStopAtLevel=1.

To disable all JIT compilers and to run everything in interpreter, use -Xint.

like image 182
apangin Avatar answered Oct 04 '22 17:10

apangin