![]() This has real implications on CPU time consumed, especially at startup time. But as we were able to measure, compilation time for C2, is at least 10 times longer than C1. Let’s run our PetClinic application with only C1: Cpusīy default, Tiered Compilation provides background compilation using 2 threads, 1 for C1 and the other for C2. C2 in total consumes more CPU than the time to startup (App startup time 12s, C2 time 19s). The time consumed by C2 threads is part of the quota of CPU allocated for your container. We can sum up those statistics with this:Ĩ63 methods compiled with C2 took 19s in total to compile while 5,000+ methods compiled with C1 took 1.2s What we can see is C2 taking a very long time to compile a method. You can then export the list of events by selecting all the lines (CTRL+A) and right click on the selection to select Clipboard settings -> Copy as CSV and then Copy. You can have a look at the compilation information in the Event Browser tree entry on the left, and then choose Compilation in Event types Tree in the middle. I have opened both files into JDK Mission Control: Java -XX:StartFlightRecording=dumponexit=true,filename=C1.jfr,settings=compile -XX:TieredStopAtLevel=1 -jar target/spring-petclinic-2.3.0.BUILD-SNAPSHOT.jar ![]() The option CICompilerCount allow you to specify this number, but by default in Tiered Compilation mode there is 2 threads (1 per JIT Compiler): ![]() ![]() If methods are trivial (small, nothing to profile) they are directly compiled at level 1 and stop here.īut what you need to keep in mind is that the process is dynamic (thresholds are also adjusted on the fly).Īlso note that the JIT uses some threads in the background to perform the compilation.If too many methods are queued for level 4 compilation, some are sent to level 2.The nominal path for most of the methods are level 0 (Interpretation), level 3 (C1 + Full Profiling) and level 4 (C2) Here is a description of the different levels of compilation: So first, the JVM JIT compiles with C1 to quickly reach native code, but with profiling and at some point, C2 kicks-in and it recompiles for more aggressive and time consuming optimizations. Nowadays, with Tiered Compilation we can benefit from both JITs at the same time. C2 was made for server applications, with at least 2 cores (server-class machine), focused on reaching peak performance but with less time constraints. C1 is focusing on startup time and reaching native performance quickly. C1 was made for client applications, with the assumption that desktop machines (at that time) had one core. Before that, there were those 2 JITs, but you had to choose between the 2. It means that the 2 JIT compilers (C1 & C2 are used in combination). Since JDK 8, Tiered Compilation was introduced and made by default. If it could make sense to put 1.5 or 2.5 on an already multi-core machine, putting less than a core has different implications… Tiered Compilation The kernel is dealing with that using cpu scheduling quota (see CFS bandwidth). Yes, with docker, for example, we can specify that the container will run with a fraction of a core (called millicores in Kubernetes). ![]() With all of that, I end up encountering people configuring a container with less than 1 core. In the same time, microservices architecture rises and the usage of container orchestration like Mesos or Kubernetes has transformed our approach of deployment. Since the introduction of containers, the way we are running JVM applications has changed a lot. Startup, containers & Tiered Compilation Introduction ![]()
0 Comments
Leave a Reply. |