RFR (S): 8151322: Implement os::set_native_thread_name() on Solaris
David Holmes
david.holmes at oracle.com
Tue Mar 15 21:31:34 UTC 2016
On 16/03/2016 12:14 AM, Gerard Ziemski wrote:
> Thanks for fixing this.
Thanks for the review.
>
> I do have one concern:
>
> #1 File src/os/solaris/vm/os_solaris.cpp
>
> 4425 // retrieve entry point for pthread_setname_np
> 4426 Solaris::_pthread_setname_np =
> 4427 (int(*)(pthread_t, const char*))dlsym(RTLD_DEFAULT, "pthread_setname_np”);
>
> According to “man dlsym” RTLD_DEFAULT can be expensive, i.e.:
>
> "If dlsym() is called with the special handle RTLD_DEFAULT, then all mach-o images in the process (except those loaded with dlopen(xxx,
> RTLD_LOCAL)) are searched in the order they were loaded. This can be a costly search and should be avoided."
What platform is that for? OSX? I don't see any such warning on Solaris
or Linux. But yes it does search the loaded libraries.
> Couldn’t we look it up on as needed basis in the implementation of "void os::set_native_thread_name(const char *name)” instead?
AFAIK we never lookup anything as-needed but always handle it at VM
initialization time. A quick grep will show that we are using
RTLD_DEFAULT in a few places across different platforms. Elsewhere we
know what library we have to search. I can try finding out which library
it should be if you think that is preferable?
Thanks,
David
>
> cheers
>
>> On Mar 15, 2016, at 1:24 AM, David Holmes <david.holmes at oracle.com> wrote:
>>
>> RFE: https://bugs.openjdk.java.net/browse/JDK-8151322
>>
>> Webrev: http://cr.openjdk.java.net/~dholmes/8151322/webrev/
>>
>> As of Solaris 11.3 pthread_set_name_np has been implemented:
>>
>> http://docs.oracle.com/cd/E53394_01/html/E54766/pthread-setname-np-3c.html#scrolltoc
>>
>> https://blogs.oracle.com/observatory/entry/named_threads
>>
>> So we can now implement os::set_native_thread_name using dynamic lookup as done on Linux. The only difference is we have 31 characters to play with instead of 16.
>>
>> Testing: - JPRT (only 11.2 systems)
>> - Manually on 11.3 - see examples in bug report
>>
>> Thanks,
>> David
>
More information about the hotspot-runtime-dev
mailing list