ghc-heap-view icon indicating copy to clipboard operation
ghc-heap-view copied to clipboard

Implement a conversion to fgl Graph

Open infinity0 opened this issue 4 years ago • 4 comments

Hi Joachim! Here's a PR that converts a HeapGraph to a fgl Graph, which you can use to do More Things with it such as output to DOT format.

ghc-vis definitely looks way more sophisticated (and it uses both ghc-heap-view and graphviz) but it looks like it's been broken for several years now sadly.

infinity0 avatar Jun 13 '20 00:06 infinity0

I forgot to mention, some parts could be tidied up, for example I exposed some internal functions. I could move these to an Internal module to keep the current API as clean as it is. But that would require moving a lot of things around so I've left it out so the PR is easier to review.

infinity0 avatar Jun 13 '20 00:06 infinity0

@infinity0 checkout https://github.com/Avi-D-coder/ghc-heap-graph, it was working, but is disappointing. I tried to get ghc-vis working, but it kept segfaulting so I re implemented it's core feature.

Unfortunately heap graphs on there own are not very useful, so I started working on a more promising aproch using ghc-generics for metadata and heap view where you can't in watch-trac.

Avi-D-coder avatar Jun 13 '20 00:06 Avi-D-coder

@Avi-D-coder that's cool, do you have some sample output? Here is mine (warning very large SVG, 3.3MB).

I notice in your code you're not attempting to compact list and string which is what this PR does - it reuses the compacting logic in ppHeapGraph. Is that what you mean by "not very useful", otherwise I'm not sure what you mean. Are you trying to recreate the functionality of ghc-vis, or what?

infinity0 avatar Jun 13 '20 00:06 infinity0

I don't remember my rational, for lists and strings, but in general the output was too big and noisy for my purpose. I wanted state diffs, replay, rendering any lazy data Generic a when appropriate (not just lists and strings), Generic was a good fit for encoding metadata, the plan was to cache the meta data and use it anywhere that the Type occurred in the heap, while periodically taking snapshots of the requested structures.

Avi-D-coder avatar Jun 13 '20 01:06 Avi-D-coder