on stack replacement vs optimal compiled code
vladimir.kozlov at oracle.com
Tue May 21 16:49:09 PDT 2013
On 5/21/13 4:10 PM, Andy Nuss wrote:
> If a long looping function gets the benefit of "on stack replacement",
> and later hotspot determines that it has been executed more than 10,000
> times, will it be recompiled again?
In most cases both compilations (OSR and normal) happen at the same time
because normal compilation is triggered by (invocation count +
backbranch (osr) count) > threshold. Next time the function is called it
will user normal compiled code.
> I read somewhere that OSR code is about half as fast as optimally jitted
Not true. The performance of the loop code (for which OSR is compiled)
should be about the same as for normal compilation. The main problem
with OSR is it is compiled before a profiling information is collected
for a code after the loop. As result the compiled code will hit uncommon
trap after loop, execution returned to Interpreter to get more profiling
and the method will be recompiled.
> code. I read somewhere else that Oracle says there is never a need to
> warmup critical functions for hotspot.
The statement is true only if by "critical" you mean "hot" (frequently
executed). If the function is called rarely but you need to compile it
to get best performance (since it is critical) then you need warm it up.
More information about the hotspot-compiler-dev