Adding Lock Instance Visualization

As promised in the blog entry before this one, I’m going to show how to easily add a new tab for visualizing lock instances. This can be done more elegantly in 4.1, so I will post an update to this once 4.1 is out the door.

This is roughly what we need to do:

  1. Start JRMC in design mode.
  2. Add a new tab.
  3. Edit the new tab to add a histogram of all the locking events grouped by lock instance, and a trace tree slaved to that histogram, showing the traces for all the events of a selected lock instance.
  4. Optionally export the tab to a plug-in that can be shared with colleagues.

Starting with #1, we need to start JRMC in design mode. This can be done by providing the parameter –designer to the jrmc launcher.

On windows you can simply provide a shortcut to JRMC and add –designer to the target:

shortcut

The designer parameter will make available an additional view in JRMC which controls switching between design and run mode in Mission Control.

Next start up Mission Control, and open up a recording you know contains some Java Blocking events. Next open up the designer view, by clicking Window | Show View | Designer View, as shown below. This view will only be available if you started Mission Control with –designer.

designer_view

I like to have the Designer View to the left, but feel free to drag-and-drop it to dock the view wherever you find is most convenient.

designer_view2

Now, to change the structure of the tabs, such as adding a new tab, you actually need to close the recording. This will show the structure of the tabs in the Designer View. Click on the CPU/Threads tab group, and select New | New Tab.

add_tab

Fill out the information about the new tab:

new_tab2

Feel free to add a nice icon. ;) Once the information is filled out, press OK and load the recording again. You should now have an empty Lock Instances tab available.

new_tab3

Press the stop button in the Designer View to enter design mode. First thing we need to do is to choose how to layout the component. Right click the surface and select Vertical Split:

vertical_split

Add a histogram to the top half, by right clicking the top half and selecting Assign Component | Histogram | Event Histogram. In the dialog that appears, do the following changes:

  • Change the Name to “Lock Instances”
  • Change General | Role to Master
  • Change General | Pie chart position to East
  • In Columns, click the Browse button, then Browse again. Select the Java Blocked event type.
  • Next click Add to add the columns to show.
    • Add the Monitor Address attribute.
    • Add the Duration field, and change the name to Count, the description to “The event count”. Change the Aggregate Function to Count. Also change the Content Type to Count. Click Pie Chart, and Sorted.
  • In Group By, click Browse and select the Monitor Address attribute.

Click the play button to see your new histogram in action:

histogram_action

To add the trace tree, press stop to enter design view. Right click the bottom space and select Assign Component | Tree | Trace Tree. In the dialog that opens, modify:

  • Change General | Role to Slave
  • Set Expanded Tree Depth to 0
  • In Columns click Browse and then Browse again in the next dialog. Select the Java Blocked event type.
  • Click add to add the Duration attribute. Select Count as Aggregate Function and Count as Content Type. Click the sorted checkbox.
  • In  Group By, click Browse and select the Stacktrace attribute.

Press play to show the ready made tab ( don’t forget to select a Lock instance in the master histogram):

done

Last but not least, export the tab to a plug-in that you can share. First close the recording to see the tab structure again. Next right click on the Flight Recording root node. Select Export UI to Plug-in. In the dialog that follows, select only the Lock Instances tab. Press OK. You will now be presented with a dialog where the plug-in name and version can be changed. Once you are happy with the settings, click OK. Next select a place to save the plug-in. Once you’ve chosen a memorable spot, press OK.

Done!

The resulting .jar file can be used by anyone simply by placing it in the missioncontrol/plugins folder.

Tip: To add a Range Selector at the top, look at how the other tabs are configured in design mode.

One Response to "Adding Lock Instance Visualization"

  1. [...] those of you who want pretty lock instance visualization, but do not want to build it yourselves, I have added a slightly more elaborate version as a downloadable plug-in here: [...]

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>