ekmett / exceptions

mtl friendly exceptions
Other
49 stars 32 forks source link

Add INLINE pragma on `try` and `tryJust` #81

Open harendra-kumar opened 3 years ago

harendra-kumar commented 3 years ago

Somehow GHC-9.0.1 is not able to inline this which blocks specialization also. See this https://github.com/composewell/streamly/issues/1061#issuecomment-864099028 . It will be helpful if there is an INLINE pragma on it.

RyanGlScott commented 3 years ago

Do you have a standalone example of a program that doesn't simplify the way you'd expect because of this? I'm not opposed to adding an INLINE pragma to these functions, but it would be helpful to have a test case to ensure that they actually are providing the benefits that one would expect.

harendra-kumar commented 3 years ago

I do not have a standalone program as a test case. But we have an elaborate benchmarking suite in streamly which shows several benchmarks regressing, on examining the core we found MonadCatch dictionary being passed, and the fix is in this commit. The regressions are around 200% as shown in this comment.

RyanGlScott commented 3 years ago

I'd like to have a regression test for this in exceptions as well (probably using inspection-testing in a different package so as not to complicate exceptions.cabal, which is a GHC boot library). Ideally, I could proactively verify that the INLINE pragma is actually doing what it says instead of reacting to user bug reports later, when the damage has already been done. This is especially important given that exceptions comes bundled with GHC, so it takes longer for changes to make their way out into the ecosystem.