RFR: 7002: Too large graphs will freeze JMC

Alex Ciminian github.com+348973+cimi at openjdk.java.net
Tue Jan 12 11:35:03 UTC 2021


This PR adds a control to limit the maximum number of nodes that can be rendered in the JMC graph view.

At the moment, rendering very large graphs makes the application unresponsive so we want to guard against this by setting a limit on the maximum number of nodes that will be rendered. When this limit is exceeded, we don't try to render our `StacktraceGraphModel` into a graphiz dot string and instead we generate a simple dot string with one node and a message informing the user that they are trying to render too many nodes.

I spent a couple of hours fighting with SWT to get the basic dropdown functionality working in the component toolbar. I took some inspiration from the FlameView component's toolbar actions and I found some (not great) examples with Google. I'm happy to use other components - this seemed to be the simplest from what I found. Please let me know if there's anything better. ��

---

![Screenshot 2021-01-10 at 18 14 39](https://user-images.githubusercontent.com/348973/104131749-4987a100-5370-11eb-8ae1-b9ee8064921f.png)

![Screenshot 2021-01-10 at 18 15 00](https://user-images.githubusercontent.com/348973/104131756-5c01da80-5370-11eb-9fe3-67e357d0fa00.png)

We will also display a similar message when the graph model has no information (no nodes):

![Screenshot 2021-01-10 at 18 14 20](https://user-images.githubusercontent.com/348973/104131741-3c6ab200-5370-11eb-8d6f-1901371ab21f.png)

---

Other things we've considered:

- ~add an icon instead of the text in the toolbar~ - we'll leave the text label for now
- ~create text labels instead of the hardcoded strings I'm using now~ - we decided not to do localisation while this view is experimental
- I was on the fence about adding a 'no limit' option in the dropdown and decided against it. I guess it's useful in development when trying out pruning strategies, but it might surprise people unfamiliar with how it works and freeze their apps. In development, we can just remove the limit when we want to try things out.

-------------

Commit messages:
 - 7002: update max graph nodes dropdown values
 - 7002: change max nodes graph view dropdown label
 - 7002: fix spotbugs format string warning
 - 7002: change display for no data in graph view
 - 7002: configure max nodes from toolbar dropdown
 - 7002: display message when graph is empty or too large

Changes: https://git.openjdk.java.net/jmc/pull/193/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jmc&pr=193&range=00
  Issue: https://bugs.openjdk.java.net/browse/JMC-7002
  Stats: 125 lines in 2 files changed: 114 ins; 0 del; 11 mod
  Patch: https://git.openjdk.java.net/jmc/pull/193.diff
  Fetch: git fetch https://git.openjdk.java.net/jmc pull/193/head:pull/193

PR: https://git.openjdk.java.net/jmc/pull/193


More information about the jmc-dev mailing list