JVM tuning and diagnostics · Topic 5 of 5
JIT compilation
Definition​
The JVM first runs your code by interpreting it, notices which methods are used a lot, and compiles those to fast machine code while the program runs. That is the JIT compiler. It is why Java programs start slower and then speed up (warm-up).
Example code​
Seeing the JIT at work
# print every method as the JIT compiles it
java -XX:+PrintCompilation -jar app.jar
# only the quick compiler (C1): faster start, lower peak speed. Useful for short-lived tools
java -XX:TieredStopAtLevel=1 -jar app.jar
# tip: benchmark after a warm-up period, or use a tool like JMH, or your numbers will be misleading
Finished this page? Track your progress (saved only in your browser).