22

HotSpot's tiered compilation uses the interpreter until a threshold of invocations (for methods) or iterations (for loops) triggers a client compilation with self-profiling. The client compilation is used until another threshold of invocations or iterations triggers a server compilation.

Printing HotSpot's flags shows the following flag values with -XX:+TieredCompilation.

intx CompileThreshold      = 10000 {pd product}        
intx Tier2CompileThreshold = 0     {product}           
intx Tier3CompileThreshold = 2000  {product}           
intx Tier4CompileThreshold = 15000 {product}           

There are too many flags for just a client and server compiler. What compilers are controlled by these flags? If not client and server, what is the purpose of the additional compilers?

Are CompileThreshold and Tier2CompileThreshold ignored in this case? What does Tier3CompileThreshold control when a client compilation is triggered? What does Tier4CompileThreshold control when a server compilation is triggered?

1 Answer 1

26

The comments in advancedThresholdPolicy.hpp discuss the different compiler tiers and the thresholds. See that file for a deeper discussion.

The system supports 5 execution levels:

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

C1 is the client compiler. C2 is the server compiler.

In the common case, the compilation goes: 0 → 3 → 4. Atypical cases are used based on C1 and C2 queue lengths. Tier 2 is used when the C2 queue length is too long so that the method can execute about 30% faster until the C2 can process the profiling information. If the method is determined to be trivial, then it is compiled with Tier 1 since it will produce the same code as Tier 4.

Thresholds are dynamically adjusted based on the length of the C1 and C2 queues.

4
  • What does CompileThreshold do in regards to all of this?
    – jocull
    Commented Dec 12, 2019 at 16:57
  • This source claims that CompileThreshold is ignored when TieredCompilation is enabled: xmlandmore.blogspot.com/2014/08/…
    – jocull
    Commented Dec 12, 2019 at 17:04
  • For future readers, I believe that TieredCompileTaskTimeout is the queue length factor mentioned above. Adjustable timeout value in milliseconds I believe (for a task sitting in C1 compiler thread queue)
    – jocull
    Commented Jan 5, 2020 at 4:01
  • Also: Tier3DelayOn is the number of methods in the C2 queue per compiler thread after which the policy no longer does 0->3 transitions but does 0->2 transitions instead. Tier3DelayOff switches the original behavior back when the number of methods in the C2 queue per compiler thread falls below the specified amount. The hysteresis is necessary to avoid jitter.
    – jocull
    Commented Jan 5, 2020 at 4:15

Not the answer you're looking for? Browse other questions tagged or ask your own question.