External Publication
Visit Post

How to profile a GHC Plugin?

Haskell Community [Unofficial] February 28, 2026
Source

Hi @Turtle, this is a good question

Since I’m not at a computer I can only give you a few hints but won’t be able to validate them or describe them in detail. Here goes…

  • Compiling GHC in profiling mode would likely work but, as you’ve noticed, is a lot of work

    • My best guess for your build failure is caused by the no_dynamic_ghc bit mixed with needing to evaluate TH splices. It’s likely fixable but read on…
    • Perhaps you could also try a more recent GHC for which prof+dyn is possible. +no_dynamic_ghc is hard to get right if at all possible
    • Your plugin’s profile will be mixed with GHC’s profile, making it harder to investigate
  • Another interesting and potentially much simpler approach to this problem could be to use the new stack sampling profiler ghc-stack-profiler: RTS Callstack profiler for GHC.

    • It doesn’t require recompiling with profiling
    • It is compatible with 9.10
    • You can probably get it to dynamically profile your plugin execution only and not GHC
    • It will produce a profile whenever your plugin runs (so yes when running stack build of another package using that plugin)
    • The drawback is that this profiling mode is still in its early days and it may be harder to get good results since the stack sampling is less precise than the cost center approach

In any case, if you keep trying let us know how it goes. BTW, I can probably help more during the week.

Discussion in the ATmosphere

Loading comments...