Sunday, August 18, 2013

PerfSpy 8 -- PerfSpyUI, Navigate Java method invocation tree

The spying part is done. Now comes the hard part: you need to play the role of a detective. Spying gives you a lot of information, perhaps too much. If you do not have a detective’s hunch and imagination, you will be drowned in the sea of information. PerfSpy UI won’t be able to help you develop hunch and imagination (reading Agatha might), but it can help you navigate the information and aid you in your detective job. 

The main control in PerfSpyUI is a table tree written with Netbeans OutlineView.

First config perfspy-ui-config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<perfspy>
       
                1)<connection provider="com.perfspy.monitor.dao.SimpleConnectionProvider">   
                        <url>jdbc:oracle:thin:@127.0.0.1:1521:ORCL</url>                       
                        <user>PerfSpyDemo</user> 
                        <password>PerfSpyDemo </password>
               
                </connection>
               
                <ui>
                        2)<tree nodeLimit="1000000"/>  
                        3)<poll frequency="5"/> <!-- pool db every # seconds -->
                </ui>          
       
</perfspy>
1): the database where the spying information is stored.

2): In order not to occur out of memory, if the method invocation tree exceeds 1 million nodes, do not show the tree, just show the summary information.

3): PerfSpyUI can be used to monitor the spying progress. It polls the database every 5 seconds.

The main class for PerfSpyUI is com.perfspy.ui.PerfSpyAdmin

Now start up PerfSpyUI and you will see this:

PerfSpy assembles method invocation into a tree structure and present it in a tree control. The tree control is written with Netbeans OutlineView.

It shows: this spying job caught 19 methods. 5 method invocations are not healthy (colored red): one method was invoked repeatedly 5 times with the total execution time 5 seconds. Using the right-clicking menus, you can expand nodes, hide nodes or mark nodes. If a method's return or parameter values start with (More...), you can double click it and view the details. If a value is not primitive, PerfSpy shows it as ClassName@SystemHashCode.

Double click on dolphin:Dolphin@2982dc66 pops up the details of this object. An object is shown as a tree, with the fields as nodes:


Load & Event Overview tab:

Most operations are self-explanatory. The “Save” panel needs some explanation. As a detective, you’ve processed the crime scene, dusted finger prints and taken photos, now you’d like to bag the evidence. In PerfSpy terms, you can navigate the method invocation tree through the contextual menus, filter uninteresting methods, select and mark interesting methods until you have a tree that contains only the most relevant information. You can save this tree into a file. You can load the tree from the file or you can apply the investigation process into the loaded tree: applying the filtering on the loaded tree, marking and selecting nodes etc.

This concludes the basic tutorial of PerfSpy. In later blogs, I will share some tips and tricks on AspectJ. AspectJ, if you are not familiar with it, can cause hair-tearing frustrations. I have gone through quite some while writing this tool, hope you do not have to suffer. 



No comments:

Post a Comment