
The cmm of both versions sheds more light on the reason for the speedup: GHC compiles the pure version to a nice loop which does not jump back to
#8793: Improve GHC.Event.IntTable performance -------------------------------------+------------------------------------- Reporter: cdk | Owner: Type: task | Status: patch Priority: normal | Milestone: 8.0.1 Component: Core Libraries | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Thank you for taking the time to get more insight. Insight is what we need to take sensible action! the beginning of the function, but behind the stack check (the stack is needed to evaluate unevaluated buckets), while the IO version just calls itself recursively (i.e. jumps before the stack check). Interesting, though I don't yet understand the details. Could you boil out a standalone example that demonstrates just this single issue? I.e. two versions of a function, one of which repeats the stack check and one of which doesn't, and show the code side by side?
but it seems hard or impossible to correctly identity such unused arguments (I mean, it is used, but only in a function which does not use it...).
Well GHC's strictness analyser should find exactly this case. I'm puzzled why it does not. Again, could you spare a moment to make a standalone reproducer for just this issue? Or at least a smallish function I can compile in isolation to see this argument not disappearing. Thanks Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8793#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler