RFR: 6810: Create treemap viewer for JOverflow
Kangcheng Xu
kxu at openjdk.java.net
Tue Jun 9 15:57:49 UTC 2020
On Mon, 8 Jun 2020 20:27:53 GMT, Alex Macdonald <aptmac at openjdk.org> wrote:
>> This PR implements [JMC-6810: Create treemap viewer for JOverflow](https://bugs.openjdk.java.net/browse/JMC-6810). It
>> adds a treemap displaying memory usage by classes. It makes easier to spot what is consuming most of the memory. Like
>> JOverflow instance viewer, the treemap viewer utilizes the filtering feature provided by JOverflow.
>> 
>> The treemap is not included in the building by default, therefore you'll need to manually enable the
>> `org.openjdk.jmc.feature.joverflow.ext.treemap` feature explicitly. Once enabled, the treemap view part can be opened
>> in *Window* -> *Show View* -> *Other* -> *JOverflow* -> *JOverflow Treemap*.
>> ---
>>
>> The treemap view part consists of three components: the toolbar actions, the breadcrumb, and the treemap. All three
>> components are automatically updated when the JOverflow filter changes, or when a new JOverflow editor page becomes
>> active.
>>
>> ### Toolbar actions:
>>
>> 
>>
>> Buttons are enabled and disabled automatically according to the state of the treemap.
>>
>> - Zoom-in button: zoom-in to the selected node of the treemap
>> - Zoom-out button: zoom-out to the parent node of the currently expanded node of the treemap
>> - Zoom-off button: display the root node (ie. "[ROOT]" node)
>>
>> ### Breadcrumb
>>
>> 
>>
>> The breadcrumb indicates the location of the currently expanded treemap node relative to the root. Breadcrumb entries
>> are updated upon treemap expands/collapse. User interactions on the breadcrumb also updates the treemap.
>> - Left mouse click: navigate to desired zooming level.
>>
>> ### Treemap
>>
>> 
>>
>> The treemap implements the squarified treemap algorithm. Memory usage is aggregated by class and package names. The
>> larger the area, the more memory consumed by this class/package. Treemap nodes on different levels are labelled with
>> different background colours. User interactions on the treemap also updates the breadcrumb.
>> - Left mouse click: select and highlight the clicked node, allowing zooming-in with the toolbar button.
>> - Middle mouse click: display the root node (ie. "[ROOT]" node)
>> - Right mouse click: zoom-out to the parent node of the currently expanded node
>> - Left mouse double click: zoom-in to the clicked node (or to its parent node if the clicked node is a leaf)
>> - Mouse hover: displays the tooltip with the full qualified package/class name and the memory usage in a human-readable
>> format.
>>
>> ---
>>
>> Let me know what you think about the design and functionality. :)
>
> Hi! I'm slowly getting through the code so bear with me here. My first impressions are that the UI looks nice and the
> controls work as you described. The transision between views is quick and the breadcrumbs work well.
> I'm writing now to describe a NPE I'm seeing which happens when enabling the treemap view while a heap dump is
> currently open and the JOverflow page is being viewed.
> This error can happen two ways (seems to be the same problem):
>
> 1. if a JOverflow page is currently being viewed while the treepmap view is added, the error "Failed to create the
> part's controls" is displayed.
> 
> 2. if a JOverflow page is opened in a different tab (i.e, the user is looking at something else like a JFR page) and
> the treepmap view is added, the view is created with the expected with the "No JOverflow editor selected". However,
> when going back and viewing the JOverflow page that was opened prior to the treemap view, a NPE is displayed in a
> dialog.
> 
> Having said that, it just seems to be a problem with the already opened heap dump; opening another `*.hprof` file will
> display the treemap view as expected (this is a continuation of the previous gif):
> 
> Error output: java.lang.NullPointerException at
> org.openjdk.jmc.joverflow.ext.treemap.TreemapPage.bindTreemapActions(TreemapPage.java:224) at
> org.openjdk.jmc.joverflow.ext.treemap.TreemapPage.allIncluded(TreemapPage.java:220) at
> org.openjdk.jmc.joverflow.ui.JOverflowUi.updateModel(JOverflowUi.java:173) at
> org.openjdk.jmc.joverflow.ui.JOverflowUi.addModelListener(JOverflowUi.java:190) at
> org.openjdk.jmc.joverflow.ext.treemap.TreemapPageBookView.lambda$0(TreemapPageBookView.java:72) at
> org.openjdk.jmc.joverflow.ui.JOverflowEditor.addUiLoadedListener(JOverflowEditor.java:281) at
> org.openjdk.jmc.joverflow.ext.treemap.TreemapPageBookView.doCreatePage(TreemapPageBookView.java:72) at
> org.eclipse.ui.part.PageBookView.createPage(PageBookView.java:369) [...]
Hi @aptmac!
> I'm slowly getting through the code so bear with me here.
Don't worry! Thank you very much for reviewing! The process understandably takes time.
> I'm writing now to describe a NPE I'm seeing which happens when enabling the treemap view while a heap dump is
> currently open and the JOverflow page is being viewed.
I was able to reproduce the problem described. Sorry for not testing thoroughly. Such NPE is caused when the mouse
click listener binding for the toolbar buttons happens before the actual view composites get created. I've added a null
check to prevent this.
Please verify the problem is resolved as for 2278edc. Thanks!
-------------
PR: https://git.openjdk.java.net/jmc/pull/77
More information about the jmc-dev
mailing list