thoughtpolice/vacuum — Issue #1: Better indication of indirections in output graphs
Author: thoughtpolice
Created: 2011-12-02 04:51:57+00:00
State: open

Johan Tibell (@tibbe) had some great slides about Haskell performance for Stanford's "CS240h: Functional Systems in Haskell" course, located here: http://blog.johantibell.com/2011/11/slides-from-my-guest-lecture-at.html

It'd be nice if Vacuum could more clearly indicate indirections in the output graph, so you can see how many words of memory a particular value uses. Compare slide 13 of Johan's talk, the memory layout of the list `[1,2]`, with the vacuum output of the same expression:

https://github.com/thoughtpolice/vacuum/raw/master/gallery/list.png
http://johantibell.com/files/stanford-2011/performance.html#%2813%29

It's somewhat close, but from this you cannot tell how much memory is needed for the expression. In Johan's example, it's clear: all indirections accounted for, the expression requires 11 words of memory.

Effectively every node in the output graph above, as an example, needs to indicate that the node *itself* takes 1 word of memory, and every edge connected to it is another word as well. The `S#` constructors (GHC infers the literals are of type `Integer`) on the leafs also take 2 words - one for the constructor, one for the value. With this in mind, it's easy to count from the Vacuum output there's 11 words needed, but this gets much trickier and more burdensome when you're dealing with very large graphs (say, of `HashMap` or `IntMap`)