Open doyougnu opened 2 years ago
Bonus: try to correlate to too much improper inlining to more pressure on instruction caches which then cause reigster spills. Would be great to get numbers on this!
be sure to mention the part about unsafePerformIO
here: https://markkarpov.com/tutorial/ghc-optimization-and-fusion.html#how-to-control-inlining
also: https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler/core-to-core-pipeline
See this ticket as a case study: https://gitlab.haskell.org/ghc/ghc/-/issues/23122#note_487215
and also a good example of reading core and join point manipulation.
Also this ticket on the implications of -fexpose-all-unfoldings
vs INLINEABLE
https://gitlab.haskell.org/ghc/ghc/-/issues/21715#note_437347 with background here: https://github.com/haskell-unordered-containers/unordered-containers/pull/357
The basic gist is that INLINEABLE stores the unoptimized unfolding so that it can be later optimized is say another package, whereas -fexpose-all-unfoldings
stores the optimized unfolding in the interface file so that it can be inlined later. Notice the subtle difference here, it is entirely possible that INLINEABLE optimizes better that the flag because GHC will have access to the call site, whereas the flag just says: here is your optimized version and now Im done.
Also this ticket which contemplates the consequences of INLINE: https://gitlab.haskell.org/ghc/ghc/-/issues/23823
One major one being that with an INLINE pragma the float out pass is skipped
Show core and stg.