问题
I am referring to the below document by Oracle:
http://docs.oracle.com/cd/E13150_01/jrockit_jvm/jrockit/geninfo/diagnos/underst_jit.html#wp1080014
It is mentioned in the "1. The JRockit JVM Runs JIT Compilation " section that the JIT JVM has more startup time and less execution time and vice-versa for JVMs without JIT.
I am confused because as per my knowledge, JIT compiles the code as per the execution of program therefore making the compilation fast. And the code will be optimized so execution time will be fast as well.
What do they want to signify with this point? I am not understanding it properly.
回答1:
Basically what they are saying that JIT compilation takes time. HotSpot actually compiles the code twice - unoptimized first, then with optimization for frequently used parts.
So when your program starts, depending on VM type, it first runs the bytecode in interpreted mode or waits for it to compile and switches to compiled version, then if the code is used frequently, compiling it again with more optimizations. It all takes resources and time, so startup is slower, but when the program is warmed up, it runs fast.
In interpreted mode, without JIT, the VM just starts interpreting the code right away, so it starts faster, but with much worse performance.
来源:https://stackoverflow.com/questions/14907968/difference-between-a-jvm-with-and-without-jit