I understand that in the Java virtual machine (JVM), warmup is potentially required as Java loads classes using a lazy loading process and as such you want to ensure that th
I always pictured it like the following:
You as (a C++ developer) could imagine an automated iterative approach by the jvm
compiling/hotloading/replacing various bits an pieces with (the imaginary analog of) gcc -O0
,-O1
,-O2
,-O3
variants (and sometimes reverting them if it deems it neccessary)
I'm sure this it not strictly what happens but might be an useful analogy for a C++ dev.
On a standard jvm the times it takes for a snippet to be considered for jit is set by -XX:CompileThreshold
which is 1500 by default.
(Sources and jvm versions vary - but I think thats for jvm8)
Further a book which I have at hand states under Host Performace JIT Chapter (p59) that the following optimizations are done during JIT:
EDIT:
regarding comments
I think 1500 may be just enough to hint to JIT that it should compile the code into native and stop interpreting. would you agree?
I don't know if its just a hint, but since openjdk is open-source lets look at the various limits and numbers in globals.hpp#l3559@ver-a801bc33b08c (for jdk8u)
(I'm not a jvm dev this might be the completly wrong place to look)
Compiling a code into native does not necessarily mean it is also optimized.
To my understanding - true; especially if you mean -Xcomp
(force compile) - this blog even states that it prevents the jvm from doing any profiling - hence optimizing - if you do not run -Xmixed
(the default).
So a timer kicks in to sample frequently accessed native code and optimize the same. Do you know how we can control this timer interval?
I really don't know the details, but the gobals.hpp
I linked indeed defines some frequency intervals.