That looks cool! It sounds especially useful in cases where safe
FFI imports are involved as they do not show up at all in regular profiling reports (see the GHC User’s Guide).
A better solution would be to add support for profiling foreign functions to
ghc
itself.
This GHC proposal seems related: Support for profiling safe FFI calls. by AndreasPK · Pull Request #651 · ghc-proposals/ghc-proposals · GitHub (focuses on safe FFI calls, but it seems natural to have a -fprofiled-unsafe-ffi
analogous to -fprofiled-safe-ffi
as suggested there).
Thx for the useful plugin. I noticed in the examples that the timings are in “ms” is it possible to time in nano seconds?
Sure, that should not be difficult. The conversion from to ns to ms is done only when showing the actual value. Making the unit configurable sounds like a useful generalization.
Yes the proposal arose from Edsko talking with me about issues with profiling C calls in fact.
The library had more work put into the design of the interface so there might be lessons to carry over into the proposal if there is interest in seeing similar functionality integrated into GHCs profiling mode.
I don’t know if I ever put it online but I did have a proof of concept version of this functionality for GHC and for someone who knows what to change it’s not a difficult implementation. But I’m slightly torn if there is enough interest in this feature to warrant adding it to GHC, and if the proposal is any indication interest is fairly low.
If I’m wrong on this let me. The proposal primarily stalled because I perceived little interest in it so I focused on other ways to improve GHC instead.
I certainly would be interested, but I have no idea whether I am representative of course or whether it is actually worth to prioritize implementing this. Mostly, just whenever I am profiling something complex, I am reminded of this pitfall and worry a bit that what I am staring at might be very misleading.