What I want to do
I have a Java program which I am trying to improve. I suspect synchronized blocks within the code to hurt performance but I would like to make sure this is my problem before touching my code.
How I went on about it
To check if synchronized blocks are indeed the issue, I recorded the execution of my program on a test server with Flight Recorder, downloaded the created jfr
file on my desktop and opened it with Java Mission Control. However the Lock Instances
page in Java Application
does not show anything. The only clue I get is a message in the Results view which reads:
The Java Blocking rule requires event(s) to be available from the following event types: com.oracle.jdk.JavaMonitorEnter
I am therefore assuming there must be some kind of option to activate along with the flight recorder but I wasn't able to find it so far.
My question
How do you enable events from the com.oracle.jdk.JavaMonitorEnter
type to be recorded by the Java Flight Recorder ?
Or I am missing something else and there is a better way to figure out how much blocking on synchronized blocks is done in a Java program ?
My environment
I am using Oracle JDK version 1.8.0_191. The version of Java Mission Control I am using on my desktop is 6.0.0. Finally, the command I use to record my program's execution is the following:
java -XX:+UnlockCommercialFeatures -XX:+UnlockDiagnosticVMOptions -XX:+DebugNonSafepoints -XX:+FlightRecorder -XX:StartFlightRecording=settings=profile,dumponexit=true,filename=test.jfr -classpath lib/*:src/ <my program with its arguments>
I should also add that connecting to the server directly with Java Mission Control is not an option (or is it?) as I am using an ssh rebound to actually connect to it ...