RFR: 8249004: Reduce ThreadsListHandle overhead in relation to direct handshakes [v10]
David Holmes
dholmes at openjdk.java.net
Thu Nov 4 01:21:16 UTC 2021
On Wed, 3 Nov 2021 15:45:06 GMT, Daniel D. Daugherty <dcubed at openjdk.org> wrote:
>> src/hotspot/share/runtime/thread.cpp line 446:
>>
>>> 444: Thread* current_thread = nullptr;
>>> 445: if (checkTLHOnly) {
>>> 446: current_thread = Thread::current();
>>
>> This seems redundant due to line 463. You can just have a `if (!checkTLHOnly)` block here.
>
> I suspect that the way that git is displaying the diffs is confusing you.
>
> We need `current_thread` set if we get to line 474 so we have to init
> `current_thread` on line 446 for the `checkTLHOnly == true` case and
> on line 463 for the `checkTLHOnly == false` case.
>
> I could simplify the logic by always setting current thread when it is
> declared on 444, but I was trying to avoid the call to `Thread::current()`
> until I actually needed it. I thought `Thread::current()` can be expensive.
> Is this no longer the case?
Sorry I missed that line 463 is still within the else from line 447.
Thread::current() is a compiler-defined thread-local access so should be relatively cheap these days, but I have no numbers.
-------------
PR: https://git.openjdk.java.net/jdk/pull/4677
More information about the serviceability-dev
mailing list