Java Mission Control Custom Pages
After some time with JDK Flight Recorder you may find yourself repeatedly wanting to look at specific pieces of information. Java Mission Control Custom Pages custom pages provides an easy way to set up custom views of profile data.
We will use the recording from the 05_JFR_WLS project for this exercise. Open the wldf.jfr recording, and switch to the JDK Mission Control perspective.
Java Mission Control Filters
We would like a nice view of the servlet requests taking longer than 2 seconds. Start by going to the Event Browser page. Use the filter box to quickly find the Servlet Request Run event type, and then use the context menu to create a new page using the selected event type.
Right click on the name of the new page, and name it “Long Lasting Servlets”:
JDK Mission Control Attribute Filters
Add a new attribute filter on Duration:
And set it to > 2 seconds:
Now we have a custom page showing the longest lasting servlet requests:
Grouping Java Mission Control Flight Data
In the custom page, events can also be grouped. Create a new page, using the Servlet Request Run event again. Name the page Request Log. Add a new filter from attribute, this time ECID. Select isn’t null as the predicate relation.
Now remove the Type filter:
Use the context menu in the table to group by ECID:
Add a column for the longest duration in the ECID table:
Next sort the ECID table on the Longest Duration column. Select the longest lasting ECID, and next sort the List, which will now show all events with the ECID selected in the ECID table, on Start Time.
After some time rearranging the columns in the List to your liking, you should now have a nice Log of what was happening, in Start time order, for any ECID you select.
Boolean Mission Control Filter Operations
Lastly we will build a custom view in Java Mission Control to find any contention on Log4J lasting longer than 400ms, or 200ms if the contention is somewhere else, as this will neatly illustrate the use of Boolean filter operations.
First create a new page on the Java Monitor Blocked event type. Go to Java Mission Control’s Event Browser. Next use the filter box to quickly find the event type. Use the context menu to create the new page. Name the new page Log4J Contention.
Use the context menu in the List table to show the search box. (This is available in all tables.)
Inspecting Java Flight Recorder Events
In the search box, type log4j, then select one of the Java Flight Recorder events. Next add a filter from the attribute Monitor Class.
The log4j class should automatically be added for you. Disable the search from the context menu in Java Mission Control on the List table by using the context menu.
Add a new Java Mission Control filter from the attribute Duration. Set the filter predicate to be more than 400 ms.
Select the Monitor Class filter and the Duration filter both, and select Combine with AND from the context menu. Next add a filter for Monitor Class != org.apache.log4j.Logger, and Duration > 200 ms. Combine them with an AND filter, and finally combine the both AND filters with an OR filter.
Note: There is a bug (fixed in Java Mission Control 7) that makes applying AND/OR filters sometimes not immediately evaluate the expression. If that happens, try clicking in the list or select another page and return.
Adding grouping on monitor address would yield a custom page in Mission Control that looks something like this:
Here are some additional videos and articles of mine (Cameron McKenzie) about Java Mission Control and Java Flight Recorder:
- Quick Introduction to Java Mission Control
- Java Mission Control 8 Eclipse plugin Install
- Fix Java memory leaks without costly JVM heap dumps
- The performance cost of autoboxing Java primitive types
- How to start Java's JVM Flight Recorder 3 easy ways
- Performance Problems with Synchronized Methods