{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreibuyhls73bxsyd5hb3dogunzysbhlcdmk2yaoambhczekf3di42jq",
"uri": "at://did:plc:pi6woz4d47bkuws673w2il2r/app.bsky.feed.post/3mgcyxqnbf7b2"
},
"path": "/t/how-to-profile-a-ghc-plugin/13745#post_11",
"publishedAt": "2026-03-05T12:39:48.000Z",
"site": "https://discourse.haskell.org",
"tags": [
"`ghc-stack-annotations`",
"github.com",
"GitHub - fendor/ghc-stack-profiler-with-ghc-plugin: Example project profiling a GHC plugin",
"`ipedb`"
],
"textContent": "Thanks for the patience!\n\nI am still not 100% what is happening, but it looks like the following:\n\n * If you compile the plugin with `-finfo-table-map` but not ghc with `ipe` info, then `ghc-stack-profiler-speedscope` will fail to translate the `.eventlog` as the info prov entries of the plugin are not written to the eventlog. However, we can find the IPE info, so we include it in our profile, leading to the crash we observe in your example eventlog. Fun fun fun.\n * Probably even if GHC is compiled with IPE, then the info prov entries added by the plugin are probably still not written to the eventlog. Perhaps a GHC bug, or intended behaviour.\n * It looked like `lookupIPE` got stuck for some keys, but I can’t reproduce this any more. Something to keep an eye out in the future.\n\n\n\nTo summarise, profiling the plugin with `ghc-stack-profiler` is quite tricky.\n\nThe way forward may be to compile GHC with the `ipe` transformer, but not to compile the plugin with `-finfo-table-map`.\n\nTo still get a reasonable profile for your plugin, you could use `ghc-stack-annotations` to insert some cost centre stack manually. Using this approach, I produced the following speedscope image:\n\nNot great, but we can see something and with enough `StackAnnotation`s, the profile might be helpful.\nNote, this only works with GHC 9.14.1+.\n\n\n\nSo, I am getting _something_ , but it is hard to argue this is particularly useful as is.\n\nIt is also quite unfortunate, that it is quite difficult to use `StackAnnotations` reliably in non IO code.\n\nHere is my example project:\n\ngithub.com\n\n### GitHub - fendor/ghc-stack-profiler-with-ghc-plugin: Example project profiling a GHC plugin\n\nExample project profiling a GHC plugin\n\n* * *\n\nWild ideas to get IPE information for the plugin as well:\n\nWe need the IPE info from the plugin. We could try to index them somehow via `ipedb` and then instruct `ghc-stack-profiler-speedscope` to use `ipedb` to find IPE info instead of relying on the `.eventlog`.\n\nBut how do we get the IPE info from the plugin? I am not sure.",
"title": "How to profile a GHC Plugin?"
}