Skip to content
  • Alexis King's avatar
    Add INLINABLE pragmas to most overloaded combinators · ce416997
    Alexis King authored and Herbert Valerio Riedel's avatar Herbert Valerio Riedel committed
    This adds INLINABLE pragmas to most exported combinators, which enables
    cross-module specialization of the Stream constraint (which can in turn
    enable further optimizations). This improves performance of these
    combinators in scenarios where GHC chooses not to inline them, since
    they may still be specialized instead.
    
    This change is primarily in response to a performance regression
    discovered by the GHC performance test suite when running haddock (since
    haddock uses parsec). The full discussion is available here:
    
        ghc/ghc!3041
    
    The gist is that, without these pragmas, performance relies too heavily
    on inlining heuristics working out in our favor, and subtle changes in
    the optimizer can cause regressions.
    
    The GHC performance tests suggest this patch reliably reduces runtime of
    haddock on base by 7–9% and allocation by 3–5%. Pretty good for doing
    something so simple!
    ce416997