GHC Profiling a Cabal Project with an Interactive Application

I have a bit of a follow up question here. I followed the instructions @velveteer gave to setup heap profiling. This works great, thank you!

But sometimes the names that show up in heap profiling are names I have never seen before. E.g., in profiling by cost center, I see $w$c<> and, more generally, I see $c followed by the name of a familiar function. What do these notations mean? I have had trouble finding some sort of explanation for what these mean. I’m using late, top-level cost centers. So my guess is these names are the result of some sort of GHC transformation.

Is there a resource that collects all the names I might come across in a heap analysis?

I’m not sure if there is a resource like that at present.

You are right that these are the result of transformations done by GHC. $w refers to a worker function from the worker-wrapper transformation. $c refers to class method dictionaries.

In general you shouldn’t have to worry about these too much when analyzing the profiles. The familiar parts of the identifiers should help point you towards what’s happening.

If you do want to dig into it, you can take a look at the compiler’s intermediate Core representation. This will include the definitions corresponding to all of these, and then you can see what they are actually doing. The Haskell unfolder recently had an episode about Core: The Haskell Unfolder Episode 9: GHC Core - Well-Typed: The Haskell Consultants

But there’s no pressure to dig into this, which can be a big topic. Most of the time you can make sense of it just by matching things back to the normal functions in your code.

1 Like