Wednesday, 11 March 2015

Java Flight Recorder since jdk 1.8.0_40 / Further comments on safe points

I refer you my first blog post on this subject where I went through the fundamentals of Java Flight Recorder.

The really annoying thing about the tool is that in order to be able to run JFR against your program, the program had to be started with the system properties:

-XX:+UnlockCommercialFeatures -XX:+FlightRecorder. 
This is not always convenient or even possible in certain runtime environments or where the process has been running a long time and is in a particular state that you would like to profile rather than restart.

Enter the latest jdk 1.8.0_40. With this build of the jdk you no longer need to have those options enabled when you started the java program. Just launch jmc and select your process as per normal and you will be presented with this dialog box.


You will be able to enable those command line options dynamically.  An excellent improvement to this excellent product!

Whilst on the topic of command line options for JFR I've started using this system property when running my programs. -XX:+DebugNonSafepoints 

According to the documentation:
One nice property of the JFR method profiler is that it does not require threads to be at safe points in order for stacks to be sampled. However, since the common case is that stacks will only be walked at safe points, HotSpot normally does not provide metadata for non-safe point parts of the code, which means that such samples will not be properly resolved to the correct line number and BCI. That is, unless you specify:
-XX:+UnlockDiagnosticVMOptions -XX:+DebugNonSafepoints 
With DebugNonSafepoints, the compiler will generate the necessary metadata for the parts of the code not at safe points as well. 

To my mind the whole point of using JFR as opposed to YourKit etc is that it doesn't have to respect safe points and you can get more accurate stats about where time is actually being spent. I have seen evidence of this even without using this system property. But with this option enabled I expect the debug stats are even more accurate. I had a situation where I was looking for hotspot and JFR pointed me to a high level method which didn't help me at all. I then enabled the DebugNonSafepoints JFR pointed me to the exact point in the code where hotspot actually lay - fantastic!

6 comments:

  1. iZombie Season 3 will portray Liv gulping down the brain of a dominatrix. Therefore, we can expect the upcoming installment to be more engaging than the previous ones. iZombie Season 3 Cast

    ReplyDelete
  2. I’ve been surfing online more than three hours today, yet I never found any interesting article like yours. It’s pretty worth enough for me. In my opinion, if all webmasters and bloggers made good content as you did, the web will be a lot more useful than ever before. iRec

    ReplyDelete
  3. It’s really such nice information to get advantage from.Flight Times 99

    ReplyDelete
  4. Quickbooks tool hub eliminates all types of errors related to quickbooks. Many businesses deploy quickbooks for accounting purposes. So it is necessary to protect it so go ahead and install Quickbooks tool hub. It is a great tool to remove all errors.

    ReplyDelete