[commit: ghc] master: Improve strictness analysis for exceptions (7c0fff4)

git at git.haskell.org git at git.haskell.org
Tue Jul 21 12:26:01 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/7c0fff41789669450b02dc1db7f5d7babba5dee6/ghc

>---------------------------------------------------------------

commit 7c0fff41789669450b02dc1db7f5d7babba5dee6
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Tue Jul 21 12:28:42 2015 +0100

    Improve strictness analysis for exceptions
    
    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.


>---------------------------------------------------------------

7c0fff41789669450b02dc1db7f5d7babba5dee6
 compiler/basicTypes/Demand.hs   | 10 +++---
 compiler/prelude/primops.txt.pp | 33 +++++++++++++----
 compiler/stranal/DmdAnal.hs     | 79 +++++++++++++++++++++++++++--------------
 3 files changed, 85 insertions(+), 37 deletions(-)

Diff suppressed because of size. To see it, use:

    git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 7c0fff41789669450b02dc1db7f5d7babba5dee6


More information about the ghc-commits mailing list