Skip to the content.

Visualization Libraries for ghc-debug

This page serves as a conclusion to my Google Summer of Code project this past summer.

I had great fun this summer working on ghc-debug. Thank you so much to the community at #ghc on IRC for being so welcoming to me, and to Matthew Pickering for mentoring me.

https://summerofcode.withgoogle.com/projects/#6368742172262400

Completed Work

Examples and Pretty Pictures!

The following visualizations are all from analyzing the following classic Haskell space leak, using my newly created library functions.

The value of the lazy MVar is not evaluated until it has to be printed, causing a leak in the form of a linked list of thunks.

main :: IO ()
main = withGhcDebug $ do
    mvar <- newMVar (1 :: Int)
    replicateM_ 50 $ modifyMVar_ mvar (\x -> return (x+1))
    putStrLn "Hit Enter to continue...\n"
    _ <- getLine

    replicateM_ 100 $ modifyMVar_ mvar (\x -> return (x+1))
    putStrLn "Hit Enter to continue..."
    _ <- getLine

    replicateM_ 150 $ modifyMVar_ mvar (\x -> return (x+1))
    putStrLn "Hit Enter to continue..."
    _ <- getLine

    -- Prevent GC by using the MVar
    val <- takeMVar mvar
    putStrLn . show $ val

Flame Graph

Flame graph for lazy thunk

Heap Census

Click to open in new page

Heap Census over Time (Stacked Area)

Click to open in new page

TODOs: How to Further Improve ghc-debug