nomeata / ghc-heap-view

Extract the heap representation of Haskell values and thunks
BSD 3-Clause "New" or "Revised" License
50 stars 19 forks source link

Implement a conversion to fgl Graph #31

Open infinity0 opened 4 years ago

infinity0 commented 4 years ago

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 commented 4 years ago

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.

Avi-D-coder commented 4 years ago

@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.

infinity0 commented 4 years ago

@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?

Avi-D-coder commented 4 years ago

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.