JDK-8151322 : Implement os::set_native_thread_name() on Solaris
Type:Enhancement
Component:hotspot
Sub-Component:runtime
Affected Version:9
Priority:P3
Status:Resolved
Resolution:Fixed
OS:solaris
CPU:generic
Submitted:2016-03-04
Updated:2022-04-28
Resolved:2016-04-11
The Version table provides details related to the release that this issue/RFE will be addressed.
Unresolved : Release in which this issue/RFE will be addressed. Resolved: Release in which this issue/RFE has been resolved. Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.
Given it is not expected that pthread_setname_np will be present on most systems a concern was raised about the use of dlsym(RTLD_DEFAULT, ...) to search for it - due to the startup cost. I instrumented the code and add the alternative of dlopen(libc) plus dlsym. Here's the result from a set of "java -version" runs
pthread_setname_np rtld_default time: 26539
pthread_setname_np dlopen+dlsym time: 22175
pthread_setname_np rtld_default time: 32191
pthread_setname_np dlopen+dlsym time: 12342
pthread_setname_np rtld_default time: 21413
pthread_setname_np dlopen+dlsym time: 12399
pthread_setname_np rtld_default time: 16658
pthread_setname_np dlopen+dlsym time: 12000
pthread_setname_np rtld_default time: 19341
pthread_setname_np dlopen+dlsym time: 19167
pthread_setname_np rtld_default time: 20957
pthread_setname_np dlopen+dlsym time: 12642
pthread_setname_np rtld_default time: 20798
pthread_setname_np dlopen+dlsym time: 12511
pthread_setname_np rtld_default time: 22653
pthread_setname_np dlopen+dlsym time: 12578
while there is a lot of variance in the dlopen case it is nearly twice as fast in the best case and always faster. So even though the absolute cost is only 20+ microseconds I will convert to the dlopen form as it is just as simple.
16-03-2016
Example with a very long name truncated at 31 characters:
> ps -L -o pid,lwp,lname,fname
PID LWP LNAME COMMAND
12116 1 - java
12116 2 DavidsVeryLongThreadNameThatSho java
12116 3 VM Thread java
12116 4 Reference Handler java
12116 5 Finalizer java
12116 6 Signal Dispatcher java
12116 7 Service Thread java
12116 8 VM Periodic Task Thread java
12117 1 - ps
9947 1 - bash
(running with -Xint and -XX:+UseSerialGC to get rid of all the GC and compiler threads)
I will take this RFE. We already do the dynamic lookup on Linux so it is trivial to copy across to Solaris.
15-03-2016
Thanks for that. Interesting to see the 31 byte limit.
07-03-2016
Sorry for an extra '_' in the function name, which has been fixed in the Description.
https://blogs.oracle.com/observatory/entry/named_threads
http://docs.oracle.com/cd/E53394_01/html/E54766/pthread-setname-np-3c.html#scrolltoc
07-03-2016
It will need to be dynamically looked up.
Can you point to the documentation for this function please.