Java Reference
In-Depth Information
Compilation Threads
Compilation Thresholds mentioned that when a method (or loop) becomes eligible for com-
pilation, it is queued for compilation. That queue is processed by one or more background
threads. This means that compilation is an asynchronous process, which is a good thing; it al-
lows the program to continue executing even while the code in question is being compiled. If
a method is compiled using standard compilation, then the next method invocation will ex-
ecute the compiled method; if a loop is compiled using OSR, then the next iteration of the
loop will execute the compiled code.
These queues are not strictly first in, first out: methods whose invocation counters are higher
have priority. So even when a program starts execution and has lots of code to compile, this
priority ordering helps to ensure that the most important code will be compiled first. (This is
another reason why the compilation ID in the PrintCompilation output can appear out of
order.)
When the client compiler is in use, the JVM starts one compilation thread; the server com-
piler has two such threads. When tiered compilation is in effect, the JVM will by default start
multiple client and server threads based on a somewhat complex equation involving double
logs of the number of CPUs on the target platform. That works out to the values shown in
Table 4-7 .
Table 4-7. Default number of C1 and C2 compiler threads for tiered compilation
Number of CPUs Number of C1 threads Number of C2 threads
1
1
1
2
1
1
4
1
2
8
1
2
16
2
6
32
3
7
64
4
8
128
4
10
Search WWH ::




Custom Search