Thread Locals (was Re: State of Loom)
Douglas Surber
douglas.surber at oracle.com
Thu Jun 4 14:58:40 UTC 2020
One more datapoint on ThreadLocal. I was crawling through a .jfr this morning and found this.
> ThreadLocal$ThreadLocalMap$Entry java.lang.ThreadLocal$ThreadLocalMap.getEntry(ThreadLocal) (JIT Compiled) 4
> ThreadLocal$ThreadLocalMap$Entry java.lang.ThreadLocal$ThreadLocalMap.access$000(ThreadLocal$ThreadLocalMap, ThreadLocal) (JIT Compiled) 4
> Object java.lang.ThreadLocal.get() (JIT Compiled) 4
> ByteBuffer sun.nio.ch.Util.getTemporaryDirectBuffer(int) (JIT Compiled) 4
> int sun.nio.ch.IOUtil.read(FileDescriptor, ByteBuffer, long, NativeDispatcher) (JIT Compiled) 4
> int sun.nio.ch.SocketChannelImpl.read(ByteBuffer) (JIT Compiled) 4
>
Putting a ThreadLocal.get inside SocketChannel.read is surprising and given the condemnation of ThreadLocals in this forum, probably suboptimal.
For what it's worth.
Douglas
More information about the loom-dev
mailing list