RFR: 8003246: Add Supplier to ThreadLocal

Remi Forax forax at univ-mlv.fr
Thu Dec 6 19:25:18 UTC 2012


On 12/06/2012 01:12 PM, Vitaly Davidovich wrote:
> Understood - I'm just trying to make sure I don't have the wrong mental
> model of this in my mind.  Taking pathology aside (e.g. code cache is full
> when time to recompile, poor tiering interaction, etc), I'd expect the fast
> inlined path to be restored assuming call site type profile (of the ones we
> care about) doesn't change after other subclasses are loaded.  Would be
> good if someone can correct that if it's inaccurate.  Apologies if this is
> slightly hijacking the thread, but it's Remi's fault :).

:)

Usually, it's inline just fine because the code just stores the 
ThreadLocal in a static field, the VM profiles the code and you get the 
fast path.
But some codes use a ThreadLocal in a non static field or use a map of 
ThreadLocal so the profile becomes bloated, and there is no inlining 
anymore.

If all loaded codes always use the same ThreadLocal (using 
ThreadLocal.withSupplier()) then, the call to the supplier is not 
inlined but you don't care because it's not part of the fast path of get.

cheers,
Rémi

>
> Sent from my phone
> On Dec 6, 2012 7:03 AM, "Doug Lea" <dl at cs.oswego.edu> wrote:
>
>> On 12/06/12 06:56, Vitaly Davidovich wrote:
>>
>>> Doug,
>>>
>>> When you see the fast to slow ThreadLocal transition due to class loading
>>> invalidating inlined get(), do you not then see it get restored back to
>>> fast
>>> mode since the receiver type in your call sites is still the monomorphic
>>> ThreadLocal (and not the unrelated subclasses)? Just trying to understand
>>> what
>>> Rémi and you are saying.
>>>
>>>
>> The possible outcomes are fairly non-deterministic, depending
>> on hotspot's mood about recompiles, tiered-compile interactions,
>> method size, Amddahl's law interactions, phase of moon, etc.
>>
>> (In j.u.c, we have learned that our users appreciate things
>> being predictably fast enough rather than being
>> unpredictably sometimes even faster but often slower.
>> So when we see such cases, as with ThreadLocal, they get added
>> to todo list.)
>>
>> -Doug
>>
>>
>>
>>
>>




More information about the core-libs-dev mailing list