Why is this Hotspot JVM option not the default? -XX: + PrintConcurrentLocks

By default, using Hotspot, a CTRL-Break thread dump will not list which threads store java.lang.concurrent locks. And I understand that with these locks Hotspot cannot have information about which stack stack a lock was acquired on. If you add the JVM -XX:+PrintConcurrentLocks , then the CTRL-Break stack dump will display (after tracing the thread stack) any simultaneous locks held by this frame. For instance:

 "D-Java-5-Lock" prio=6 tid=0x00000000069a1800 nid=0x196c runnable [0x000000000770f000] java.lang.Thread.State: RUNNABLE at com.Tester.longDelay(Tester.java:41) at com.Tester$D.run(Tester.java:88) Locked ownable synchronizers: - <0x00000007d6030898> (a java.util.concurrent.locks.ReentrantLock$NonfairSync) 

Without this option, it is not possible to determine which thread holds this lock after death. Why is this parameter not the default? Is there an unobvious performance or forfeit? When I search to find a discussion of this, nothing comes.

+6
source share
3 answers

I asked Oracle (my employer has a support contact), and the answer is mainly that this option is safe to use and that many pure diagnostic functions are disabled by default, and this is one of these options. IMO, if the diagnostic function is safe and stable and does not introduce a performance penalty, then it should be enabled by default. This does not seem to be the point of view of (then) Sun and (now) Oracle.

+2
source

Well, I assume it is unstable, or supporting JVMs (Sun-now-Oracle) just don't want to support it as a supported function. You can say this simply by prefixing -XX: ::

The options specified in -XX are unstable and are not recommended for casual use. These parameters are subject to change without notice.

- from Java Parameters HotSpot VM

Also from this page this option can be dynamically enabled or disabled using the JDK management interface, so you can enable it using MXBean if you need to.

Flags marked as managed are dynamically written through the JDK management interface (com.sun.management.HotSpotDiagnosticMXBean API), as well as through the JConsole. The "Monitoring and managing Java SE 6 platform applications" section in Figure 3 shows an example. Managed flags can also be set via jinfo -flag.

Finally, the jstack Stack Trace tool can perform the same functions at any time, without requiring it to be turned on all the time.

+2
source

Because only ReentrantLocks knows which streams they are associated with. To get this information about the Runtime implementation of this method, go to the heap to find all the locks and their threads.

0
source

Source: https://habr.com/ru/post/895100/


All Articles