carrier local

Dmitry Zaslavsky dmitry.zaslavsky at gmail.com
Fri Apr 3 00:36:26 UTC 2020


I agree with Thomas 
There is a relatively common pattern to avoid synchronization is to keep per thread state and only when needed to pull together all the data.
Carrier locals are perfect for that.

In fact they would be even more useful with loom than in the current system as we will likely end up with less carrier threads than currently with threads.

Profiling and statistics fit perfectly into this.

Another use case we have is per thread pre allocated direct buffers for small space to communicate with native code.

Sure having a custom scheduler is a solution but probably an overkill for most use cases


> On Apr 2, 2020, at 4:06 PM, Thomas May <tmay at clearwateranalytics.com> wrote:
> 
> LongAdder would be a good example where you'd want carrier local storage rather than thread local.  Having it ThreadLocal would allocate more memory than necessary.
> 
> Another example is SimpleDateFormat.
> 
> In fact, I'd think whenever you are using ThreadLocals to avoid synchronization you probably would be happy using carrier local instead of ThreadLocal.
> 
> ________________________________


More information about the loom-dev mailing list