Monitoring Locks with Java Flight Recorder and Java Mission Control












7















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 ...










share|improve this question





























    7















    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 ...










    share|improve this question



























      7












      7








      7


      0






      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 ...










      share|improve this question
















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 26 '18 at 6:56







      Patrick

















      asked Nov 26 '18 at 5:26









      PatrickPatrick

      140110




      140110
























          1 Answer
          1






          active

          oldest

          votes


















          4














          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>...





          share|improve this answer



















          • 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 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













          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
          });


          }
          });














          draft saved

          draft discarded


















          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









          4














          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>...





          share|improve this answer



















          • 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 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


















          4














          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>...





          share|improve this answer



















          • 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 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
















          4












          4








          4







          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>...





          share|improve this answer













          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>...






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 26 '18 at 7:50









          PatrickPatrick

          140110




          140110








          • 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 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
















          • 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 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










          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




















          draft saved

          draft discarded




















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Contact image not getting when fetch all contact list from iPhone by CNContact

          count number of partitions of a set with n elements into k subsets

          A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks