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.

To download the current JDK release, click here.
JDK 8 JDK 9 Other
8u351Fixed 9 b116Fixed openjdk8u222Fixed
Related Reports
Relates :  
Description
Now pthread_setname_np() is available on Solaris 11.3.
Comments
Fix Request 8u. Solaris piece of JDK-7102541. Patch applies cleanly net of line numbers.
13-05-2019

URL: http://hg.openjdk.java.net/jdk9/jdk9/hotspot/rev/f3788f7eccd4 User: lana Date: 2016-04-27 18:46:27 +0000
27-04-2016

URL: http://hg.openjdk.java.net/jdk9/hs-rt/hotspot/rev/f3788f7eccd4 User: dholmes Date: 2016-04-11 08:35:04 +0000
11-04-2016

Re-test results example: PID LWP LNAME COMMAND 13370 1 - ps 13363 1 - java 13363 2 DavidsVeryLongThreadNameThatSho java 13363 3 GC Thread#0 java 13363 4 GC Thread#1 java 13363 5 GC Thread#2 java 13363 6 GC Thread#3 java 13363 7 GC Thread#4 java 13363 8 GC Thread#5 java 13363 9 GC Thread#6 java 13363 10 GC Thread#7 java 13363 11 GC Thread#8 java 13363 12 GC Thread#9 java 13363 13 G1 Refine#9 java 13363 14 G1 Refine#8 java 13363 15 G1 Refine#7 java 13363 16 G1 Refine#6 java 13363 17 G1 Refine#5 java 13363 18 G1 Refine#4 java 13363 19 G1 Refine#3 java 13363 20 G1 Refine#2 java 13363 21 G1 Refine#1 java 13363 22 G1 Refine#0 java 13363 23 G1 Young RemSet Sampling java 13363 24 G1 Main Marker java 13363 25 G1 Marker#0 java 13363 26 G1 Marker#1 java 13363 27 G1 Marker#2 java 13363 28 VM Thread java 13363 29 Reference Handler java 13363 30 Finalizer java 13363 31 Surrogate Locker Thread (Concur java 13363 32 Signal Dispatcher java 13363 33 C2 CompilerThread0 java 13363 34 C2 CompilerThread1 java 13363 35 C2 CompilerThread2 java 13363 36 C1 CompilerThread3 java 13363 37 Sweeper thread java 13363 38 Service Thread java 13363 39 VM Periodic Task Thread java
16-03-2016

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)
15-03-2016

Sample output using updated ps command: e> ps -L -o pid,lwp,lname,fname PID LWP LNAME COMMAND 10001 1 - ps 9947 1 - bash 10000 1 - java 10000 2 - java 10000 3 GC Thread#0 java 10000 4 GC Thread#1 java 10000 5 GC Thread#2 java 10000 6 GC Thread#3 java 10000 7 GC Thread#4 java 10000 8 GC Thread#5 java 10000 9 GC Thread#6 java 10000 10 GC Thread#7 java 10000 11 GC Thread#8 java 10000 12 GC Thread#9 java 10000 13 G1 Refine#9 java 10000 14 G1 Refine#8 java 10000 15 G1 Refine#7 java 10000 16 G1 Refine#6 java 10000 17 G1 Refine#5 java 10000 18 G1 Refine#4 java 10000 19 G1 Refine#3 java 10000 20 G1 Refine#2 java 10000 21 G1 Refine#1 java 10000 22 G1 Refine#0 java 10000 23 G1 Young RemSet Sampling java 10000 24 G1 Main Marker java 10000 25 G1 Marker#0 java 10000 26 G1 Marker#1 java 10000 27 G1 Marker#2 java 10000 28 VM Thread java 10000 29 Reference Handler java 10000 30 Finalizer java 10000 31 Surrogate Locker Thread (Concur java 10000 32 Signal Dispatcher java 10000 33 C2 CompilerThread0 java 10000 34 C2 CompilerThread1 java 10000 35 C2 CompilerThread2 java 10000 36 C1 CompilerThread3 java 10000 37 Sweeper thread java 10000 38 Service Thread java 10000 39 VM Periodic Task Thread java (the "java" is the process name)
15-03-2016

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.
05-03-2016