• Simon Peyton Jones's avatar
    Improve strictness analysis for exceptions · 7c0fff41
    Simon Peyton Jones authored
    Two things here:
    
    * For exceptions-catching primops like catch#, we know
      that the main argument function will be called, so
      we can use strictApply1Dmd, rather than lazy
    
      Changes in primops.txt.pp
    
    * When a 'case' scrutinises a I/O-performing primop,
      the Note [IO hack in the demand analyser] was
      throwing away all strictness from the code that
      followed.
    
      I found that this was causing quite a bit of unnecessary
      reboxing in the (heavily used) function
      GHC.IO.Handle.Internals.wantReadableHandle
    
      So this patch prevents the hack applying when the
      case scrutinises a primop.  See the revised
      Note [IO hack in the demand analyser]
    
    Thse two things buy us quite a lot in programs that do a lot of IO.
    
            Program           Size    Allocs   Runtime   Elapsed  TotalMem
    --------------------------------------------------------------------------------
                hpg          -0.4%     -2.9%     -0.9%     -1.0%     +0.0%
    reverse-complem          -0.4%    -10.9%    +10.7%    +10.9%     +0.0%
             simple          -0.3%     -0.0%    +26.2%    +26.2%     +3.7%
             sphere          -0.3%     -6.3%      0.09      0.09     +0.0%
    --------------------------------------------------------------------------------
                Min          -0.7%    -10.9%     -4.6%     -4.7%     -1.7%
                Max          -0.2%     +0.0%    +26.2%    +26.2%     +6.5%
     Geometric Mean          -0.4%     -0.3%     +2.1%     +2.1%     +0.1%
    
    I think the increase in runtime for 'simple' is measurement error.
    7c0fff41
Demand.hs 70.8 KB