Monitoring Locks with Java Flight Recorder and Java Mission Control
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 ...
java java-8 jmc jfr java-mission-control
add a comment |
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 ...
java java-8 jmc jfr java-mission-control
add a comment |
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 ...
java java-8 jmc jfr java-mission-control
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 ...
java java-8 jmc jfr java-mission-control
java java-8 jmc jfr java-mission-control
edited Nov 26 '18 at 6:56
Patrick
asked Nov 26 '18 at 5:26
PatrickPatrick
145110
145110
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
A liitle more research on my own provided me with the answer.
The JavaMonitorEnter events (and other events that one would like to monitor) need to be specified in a flight recorder configuration file. In this situation, I was using the profile
configuration which is provided along with the default
configuration with the Oracle JDK.
I created my own configuration using Java Mission Control. This blog was very helpful in presenting how to find the tool to create custom recording configurations in Java Mission Control.
I then exported my newly created configuration, uploaded it on my test environment and specified this configuration in my command (below the modified option only):
-XX:StartFlightRecording=settings=/home/<username>/Custom,<other options>...
1
In Java 8, the event is called "java/monitor_enter", and should be enabled by default for both default and profile configurations.... So you should have seen it from the beginning.. (JMC 6 translates from the old Java 8 event ids (java/monitor_enter) into the new Java 9+ ids (JavaMonitorEnter) )
– Klara
Nov 27 '18 at 8:12
1
@Klara You are right, the java/monitor_enter event is activated in bothdefault
andprofile
configurations. Except that the threshold in these settings is too long for my application (10ms in theprofile
configuration, 20ms in thedefault
configuration). In my application, the individual blockings I was trying to monitor were about 20 microseconds long so they would not show with these previous configurations.
– Patrick
Nov 27 '18 at 8:28
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53475177%2fmonitoring-locks-with-java-flight-recorder-and-java-mission-control%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
A liitle more research on my own provided me with the answer.
The JavaMonitorEnter events (and other events that one would like to monitor) need to be specified in a flight recorder configuration file. In this situation, I was using the profile
configuration which is provided along with the default
configuration with the Oracle JDK.
I created my own configuration using Java Mission Control. This blog was very helpful in presenting how to find the tool to create custom recording configurations in Java Mission Control.
I then exported my newly created configuration, uploaded it on my test environment and specified this configuration in my command (below the modified option only):
-XX:StartFlightRecording=settings=/home/<username>/Custom,<other options>...
1
In Java 8, the event is called "java/monitor_enter", and should be enabled by default for both default and profile configurations.... So you should have seen it from the beginning.. (JMC 6 translates from the old Java 8 event ids (java/monitor_enter) into the new Java 9+ ids (JavaMonitorEnter) )
– Klara
Nov 27 '18 at 8:12
1
@Klara You are right, the java/monitor_enter event is activated in bothdefault
andprofile
configurations. Except that the threshold in these settings is too long for my application (10ms in theprofile
configuration, 20ms in thedefault
configuration). In my application, the individual blockings I was trying to monitor were about 20 microseconds long so they would not show with these previous configurations.
– Patrick
Nov 27 '18 at 8:28
add a comment |
A liitle more research on my own provided me with the answer.
The JavaMonitorEnter events (and other events that one would like to monitor) need to be specified in a flight recorder configuration file. In this situation, I was using the profile
configuration which is provided along with the default
configuration with the Oracle JDK.
I created my own configuration using Java Mission Control. This blog was very helpful in presenting how to find the tool to create custom recording configurations in Java Mission Control.
I then exported my newly created configuration, uploaded it on my test environment and specified this configuration in my command (below the modified option only):
-XX:StartFlightRecording=settings=/home/<username>/Custom,<other options>...
1
In Java 8, the event is called "java/monitor_enter", and should be enabled by default for both default and profile configurations.... So you should have seen it from the beginning.. (JMC 6 translates from the old Java 8 event ids (java/monitor_enter) into the new Java 9+ ids (JavaMonitorEnter) )
– Klara
Nov 27 '18 at 8:12
1
@Klara You are right, the java/monitor_enter event is activated in bothdefault
andprofile
configurations. Except that the threshold in these settings is too long for my application (10ms in theprofile
configuration, 20ms in thedefault
configuration). In my application, the individual blockings I was trying to monitor were about 20 microseconds long so they would not show with these previous configurations.
– Patrick
Nov 27 '18 at 8:28
add a comment |
A liitle more research on my own provided me with the answer.
The JavaMonitorEnter events (and other events that one would like to monitor) need to be specified in a flight recorder configuration file. In this situation, I was using the profile
configuration which is provided along with the default
configuration with the Oracle JDK.
I created my own configuration using Java Mission Control. This blog was very helpful in presenting how to find the tool to create custom recording configurations in Java Mission Control.
I then exported my newly created configuration, uploaded it on my test environment and specified this configuration in my command (below the modified option only):
-XX:StartFlightRecording=settings=/home/<username>/Custom,<other options>...
A liitle more research on my own provided me with the answer.
The JavaMonitorEnter events (and other events that one would like to monitor) need to be specified in a flight recorder configuration file. In this situation, I was using the profile
configuration which is provided along with the default
configuration with the Oracle JDK.
I created my own configuration using Java Mission Control. This blog was very helpful in presenting how to find the tool to create custom recording configurations in Java Mission Control.
I then exported my newly created configuration, uploaded it on my test environment and specified this configuration in my command (below the modified option only):
-XX:StartFlightRecording=settings=/home/<username>/Custom,<other options>...
answered Nov 26 '18 at 7:50
PatrickPatrick
145110
145110
1
In Java 8, the event is called "java/monitor_enter", and should be enabled by default for both default and profile configurations.... So you should have seen it from the beginning.. (JMC 6 translates from the old Java 8 event ids (java/monitor_enter) into the new Java 9+ ids (JavaMonitorEnter) )
– Klara
Nov 27 '18 at 8:12
1
@Klara You are right, the java/monitor_enter event is activated in bothdefault
andprofile
configurations. Except that the threshold in these settings is too long for my application (10ms in theprofile
configuration, 20ms in thedefault
configuration). In my application, the individual blockings I was trying to monitor were about 20 microseconds long so they would not show with these previous configurations.
– Patrick
Nov 27 '18 at 8:28
add a comment |
1
In Java 8, the event is called "java/monitor_enter", and should be enabled by default for both default and profile configurations.... So you should have seen it from the beginning.. (JMC 6 translates from the old Java 8 event ids (java/monitor_enter) into the new Java 9+ ids (JavaMonitorEnter) )
– Klara
Nov 27 '18 at 8:12
1
@Klara You are right, the java/monitor_enter event is activated in bothdefault
andprofile
configurations. Except that the threshold in these settings is too long for my application (10ms in theprofile
configuration, 20ms in thedefault
configuration). In my application, the individual blockings I was trying to monitor were about 20 microseconds long so they would not show with these previous configurations.
– Patrick
Nov 27 '18 at 8:28
1
1
In Java 8, the event is called "java/monitor_enter", and should be enabled by default for both default and profile configurations.... So you should have seen it from the beginning.. (JMC 6 translates from the old Java 8 event ids (java/monitor_enter) into the new Java 9+ ids (JavaMonitorEnter) )
– Klara
Nov 27 '18 at 8:12
In Java 8, the event is called "java/monitor_enter", and should be enabled by default for both default and profile configurations.... So you should have seen it from the beginning.. (JMC 6 translates from the old Java 8 event ids (java/monitor_enter) into the new Java 9+ ids (JavaMonitorEnter) )
– Klara
Nov 27 '18 at 8:12
1
1
@Klara You are right, the java/monitor_enter event is activated in both
default
and profile
configurations. Except that the threshold in these settings is too long for my application (10ms in the profile
configuration, 20ms in the default
configuration). In my application, the individual blockings I was trying to monitor were about 20 microseconds long so they would not show with these previous configurations.– Patrick
Nov 27 '18 at 8:28
@Klara You are right, the java/monitor_enter event is activated in both
default
and profile
configurations. Except that the threshold in these settings is too long for my application (10ms in the profile
configuration, 20ms in the default
configuration). In my application, the individual blockings I was trying to monitor were about 20 microseconds long so they would not show with these previous configurations.– Patrick
Nov 27 '18 at 8:28
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53475177%2fmonitoring-locks-with-java-flight-recorder-and-java-mission-control%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown