Skip to content
  • Simon Peyton Jones's avatar
    Optimisation in Unique.Supply · 9454511b
    Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
    This patch switches on -fno-state-hack in GHC.Types.Unique.Supply.
    
    It turned out that my fixes for #18078 (coercion floating) changed the
    optimisation pathway for mkSplitUniqSupply in such a way that we had
    an extra allocation inside the inner loop.  Adding -fno-state-hack
    fixed that -- and indeed the loop in mkSplitUniqSupply is a classic
    example of the way in which -fno-state-hack can be bad; see #18238.
    
    Moreover, the new code is better than the old.  They allocate
    the same, but the old code ends up with a partial application.
    The net effect is that the test
        perf/should_run/UniqLoop
    runs 20% faster!   From 2.5s down to 2.0s.  The allocation numbers
    are the same -- but elapsed time falls. Good!
    
    The bad thing about this is that it's terribly delicate.  But
    at least it's a good example of such delicacy in action.
    
    There is a long Note [Optimising the unique supply] which now
    explains all this.
    9454511b