Does HotSpot ever stop profiling?
Vitaly Davidovich
vitalyd at gmail.com
Mon Sep 16 23:16:57 UTC 2019
On Mon, Sep 16, 2019 at 7:05 PM Stefan Reich <
stefan.reich.maker.of.eye at googlemail.com> wrote:
> Hey, thanks for your answer.
>
> So a method is normally only once C2-compiled. How does inlining fit into
> the picture? You start from the method body and inline as deeply as
> possible?
>
So saying a given method is only once compiled by C2 is slightly
misleading. What C2 compiles is actually a tree of methods. I’m going to
simplify a bit, but a method that reaches C2 compilation threshold is
queued up for a C2 compile. That method serves as the root of the
compilation tree. Callees in that method can be inlined as well, based on
profiling info + a bunch of heuristics. So you can end up with some leaf
methods inljmed and compiled in multiple call graphs. But there are also
cases where C2 will refuse to inline a method that’s already been compiled
if its resulting machine code size is over a (tunable) threshold - that’s
just 1 of the different heuristics :).
But the main point I wanted to convey is that once that blob is compiled by
C2, that blob has no counters and generally sticks around (modulo
traps/deopt or code cache pressure or some such).
>
> I always thought a method would be compiled multiple times while improving
> its inlining. But maybe that makes no sense and you can do it all in a
> single compilation effort.
>
>
> On Tue, 17 Sep 2019 at 00:47, Vitaly Davidovich <vitalyd at gmail.com> wrote:
>
>>
>>
>> On Mon, Sep 16, 2019 at 6:35 PM Stefan Reich <
>> stefan.reich.maker.of.eye at googlemail.com> wrote:
>>
>>> Here's another thing I would love to have cleared up.
>>>
>>> Once a method is C2-compiled - does it still update its invocation
>>> counters?
>>
>> Nope. C2 compiled methods run profile-free. There can be certain events
>> that trigger a deopt that will toss out the C2 method (with future C2
>> compilations off newly collected profiling possible), but it won’t be
>> counter based.
>>
>>>
>>>
>>> I would assume counting stops at that point since we have done all we
>>> could
>>> for the method. Also the invocation counting overhead is always
>>> embarrassing when fighting some C++ guys over claims on how "slow" Java
>>> is.
>>> :o)
>>>
>>> OTOH, there might be scenarios where it makes sense to have a second look
>>> at "hot" methods, even if they are C2-compiled. Not sure if that scenario
>>> exists in the current infrastructure.
>>
>> That infrastructure is called a process restart :) j/k. There’re some
>> compiler control APIs, but they’re mostly to allow JIT testing (AFAIK). I
>> think it allows manually marking a C2 method for reclaim (ie not entrant),
>> but I don’t recall the details offhand.
>>
>>>
>>>
>>> Which one is it in reality?
>>>
>>> --
>>> Stefan Reich
>>> BotCompany.de // Java-based operating systems
>>>
>> --
>> Sent from my phone
>>
>
>
> --
> Stefan Reich
> BotCompany.de // Java-based operating systems
>
--
Sent from my phone
More information about the hotspot-dev
mailing list