Video in progress
How do you read the -XX:+PrintCompilation output, and what can you learn from it?
1450 812 3 com.acme.PriceService::calculate (148 bytes)
1502 830 % 4 com.acme.Importer::run @ 37 (212 bytes)
1610 845 4 com.acme.PriceService::calculate (148 bytes)
1611 812 3 com.acme.PriceService::calculate (148 bytes) made not entrant
9120 845 4 com.acme.PriceService::calculate (148 bytes) made not entrant
9135 1203 3 com.acme.PriceService::calculate (148 bytes)
Each line is one compilation event: time, compilation ID, attribute flags (% for OSR, s for synchronized, ! for exception handler, n for native), tier level, method name and bytecode size. "made not entrant" means the code was invalidated.
📖 Answer
The columns: milliseconds since JVM start, compilation ID, flags, tier (0-4), method, @ 37 is the bytecode index for OSR, and the size in parentheses.
Reading the lines:
- 1450 ms:
calculatewas compiled with C1 (tier 3, the version that collects a profile). Normal. %and@ 37: the long loop insideImporter::runwas compiled by C2 through OSR.- 1610 ms:
calculatereached tier 4 (C2), and the old tier 3 version is "made not entrant". This is also normal, it is a replacement. - 9120 ms: the C2 version is "made not entrant". This is deoptimization now: an assumption C2 made was broken (a new class arrived, an unused branch ran). The code dropped back to tier 3 and is being profiled again.
If this cycle repeats many times for one method, you have a deoptimization storm. The cause shows up with -XX:+UnlockDiagnosticVMOptions -XX:+LogCompilation (XML, read with JITWatch) or the jdk.Deoptimization event in JFR.
What else you can see:
COMPILE SKIPPED: ...: for example, the code cache is full or the method is too big;- a hot method never reaches tier 4: check whether
-XX:TieredStopAtLevelis set.
On prod this flag produces a lot of output, but it is very useful for analyzing startup and warm-up. On a running JVM, jcmd <pid> Compiler.queue and Compiler.codelist give similar information.
Sign up to mark studied questions and save your progress.