The type class (lack of) specialization bit me with haskell-capnp; I was still not that experienced with the language when I started the project, and parameterized a bunch of performance-critical code over some type classes. When I finally used the library where this mattered, I ended up benchmarking canonicalize and found it was 200x slower than the Go implementation. I did what the author mentioned with the SPECIALIZE pragma for IO and ST s, and between that and some other tuning got it down to something that was at least in the same ballpark, but I have vague plans to just rip out the type classes and have everything in single concrete monad; in my case the type classes were not super useful anyway; I’ve never really used instances other than those two.
For anyone curious, a few months ago I also did the work to make these changes for the LLVM backend, with quite similar performance improvements https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9713 (it was my first GHC contribution so the process was pretty messy)
The type class (lack of) specialization bit me with haskell-capnp; I was still not that experienced with the language when I started the project, and parameterized a bunch of performance-critical code over some type classes. When I finally used the library where this mattered, I ended up benchmarking
canonicalizeand found it was 200x slower than the Go implementation. I did what the author mentioned with theSPECIALIZEpragma forIOandST s, and between that and some other tuning got it down to something that was at least in the same ballpark, but I have vague plans to just rip out the type classes and have everything in single concrete monad; in my case the type classes were not super useful anyway; I’ve never really used instances other than those two.For anyone curious, a few months ago I also did the work to make these changes for the LLVM backend, with quite similar performance improvements https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9713 (it was my first GHC contribution so the process was pretty messy)