1. 21 Jul, 2015 1 commit
    • 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
  2. 08 Jul, 2015 1 commit
  3. 14 Apr, 2015 1 commit
    • Simon Peyton Jones's avatar
      Zap usage info in CSE (Trac #10218) · d261d4cb
      Simon Peyton Jones authored
      Trac #10218 reports a subtle bug that turned out to be:
      
      - CSE invalidated the usage information computed
        by earlier demand analysis, by increasing sharing
      
      - that made a single-entry thunk into a multi-entry thunk
      
      - and with -feager-blackholing, that led to <<loop>>
      
      The patch fixes it by making the CSE pass zap usage information for
      let-bound identifiers.   It can be restored by -flate-dmd-anal.
      
      (But making -flate-dmd-anal the default needs some careful work;
      see Trac #7782.)
      d261d4cb
  4. 10 Apr, 2015 1 commit
  5. 07 Apr, 2015 1 commit
    • Simon Peyton Jones's avatar
      Fix a long-standing bug in the demand analyser · 9f0f99fd
      Simon Peyton Jones authored
      This patch fixes Trac #10148, an outright and egregious
      bug in the demand analyser.
      
      It is explained in Note [Demand on case-alternative binders]
      in Demand.hs.
      
      I did some other minor refactoring.
      
      To my astonishment I got some big compiler perf changes
      
      * perf/compiler/T5837: bytes allocated -76%
      * perf/compiler/T5030: bytes allocated -10%
      * perf/compiler/T3294: max bytes used  -25%
      
      Happy days
      9f0f99fd
  6. 04 Mar, 2015 1 commit
  7. 03 Dec, 2014 1 commit
  8. 04 Nov, 2014 1 commit
  9. 13 Oct, 2014 1 commit
  10. 01 Jul, 2014 1 commit
    • Simon Peyton Jones's avatar
      Fix demand analyser for unboxed types · d6ee82b2
      Simon Peyton Jones authored
      This is a tricky case exposed by Trac #9254.  I'm surprised it hasn't
      shown up before, because it's happens when you use unsafePerformIO in
      the right way.
      
      Anyway, fixed now.  See Note [Analysing with absent demand]
      in Demand.lhs
      d6ee82b2
  11. 20 Jun, 2014 1 commit
  12. 15 May, 2014 1 commit
    • Herbert Valerio Riedel's avatar
      Add LANGUAGE pragmas to compiler/ source files · 23892440
      Herbert Valerio Riedel authored
      In some cases, the layout of the LANGUAGE/OPTIONS_GHC lines has been
      reorganized, while following the convention, to
      
      - place `{-# LANGUAGE #-}` pragmas at the top of the source file, before
        any `{-# OPTIONS_GHC #-}`-lines.
      
      - Moreover, if the list of language extensions fit into a single
        `{-# LANGUAGE ... -#}`-line (shorter than 80 characters), keep it on one
        line. Otherwise split into `{-# LANGUAGE ... -#}`-lines for each
        individual language extension. In both cases, try to keep the
        enumeration alphabetically ordered.
        (The latter layout is preferable as it's more diff-friendly)
      
      While at it, this also replaces obsolete `{-# OPTIONS ... #-}` pragma
      occurences by `{-# OPTIONS_GHC ... #-}` pragmas.
      23892440
  13. 06 Mar, 2014 1 commit
    • Simon Peyton Jones's avatar
      Make the demand on a binder compatible with type (fixes Trac #8569) · 4b355cd2
      Simon Peyton Jones authored
      Because of GADTs and casts we were getting binders whose
      demand annotation was more deeply nested than made sense
      for its type.
      
      See Note [Trimming a demand to a type], in Demand.lhs,
      which I reproduce here:
      
         Note [Trimming a demand to a type]
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         Consider this:
      
           f :: a -> Bool
           f x = case ... of
                   A g1 -> case (x |> g1) of (p,q) -> ...
                   B    -> error "urk"
      
         where A,B are the constructors of a GADT.  We'll get a U(U,U) demand
         on x from the A branch, but that's a stupid demand for x itself, which
         has type 'a'. Indeed we get ASSERTs going off (notably in
         splitUseProdDmd, Trac #8569).
      
         Bottom line: we really don't want to have a binder whose demand is more
         deeply-nested than its type.  There are various ways to tackle this.
         When processing (x |> g1), we could "trim" the incoming demand U(U,U)
         to match x's type.  But I'm currently doing so just at the moment when
         we pin a demand on a binder, in DmdAnal.findBndrDmd.
      4b355cd2
  14. 01 Feb, 2014 1 commit
  15. 23 Jan, 2014 1 commit
    • Joachim Breitner's avatar
      Some polishing of the demand analyser. · 8d34ae39
      Joachim Breitner authored
      I did some refactoring of the demand analyser, because I was smelling
      some minor code smell. Most of my changes I had to undo, though,
      adding notes and testcases on why the existing code was correct after
      all.
      
      Especially the semantics of the DmdResult is confusing, as it differs in
      a DmdType and a StrictSig.
      
      I got to imrpove the readability of the code for lubDmdType, though.
      
      Also, dmdAnalRhs was a bit fishy in how it removed the demand on
      further arguments of the body, but used the DmdResult. This would be
      wrong if a body would return a demand type of "<L>m" (which currently
      does not happen).  This is now treated better in removeDmdTyArgs.
      8d34ae39
  16. 16 Jan, 2014 4 commits
  17. 10 Jan, 2014 2 commits
  18. 16 Dec, 2013 7 commits
  19. 12 Dec, 2013 4 commits
    • Joachim Breitner's avatar
      Move peelFV from DmdAnal to Demand · 6b6a30d6
      Joachim Breitner authored
      6b6a30d6
    • Simon Peyton Jones's avatar
      Improve the handling of used-once stuff · 80989de9
      Simon Peyton Jones authored
      Joachim and I are committing this onto a branch so that we can share it,
      but we expect to do a bit more work before merging it onto head.
      
      Nofib staus:
        - Most programs, no change
        - A few improve
        - A couple get worse (cacheprof, tak, rfib)
      Investigating the "get worse" set is what's holding up putting this
      on head.
      
      The major issue is this.  Consider
      
          map (f g) ys
      
      where f's demand signature looks like
      
         f :: <L,C1(C1(U))> -> <L,U> -> .
      
      So 'f' is not saturated.  What demand do we place on g?
      Answer
              C(C1(U))
      That is, the inner C1 should stay, even though f is not saturated.
      
      I found that this made a significant difference in the demand signatures
      inferred in GHC.IO, which uses lots of higher-order exception handlers.
      
      I also had to add used-once demand signatures for some of the
      'catch' primops, so that we know their handlers are only called once.
      80989de9
    • Simon Peyton Jones's avatar
      Assign strictness signatures to primitive operations · 0558911f
      Simon Peyton Jones authored
      This patch was authored by SPJ, and extracted from "Improve the handling
      of used-once stuff" by Joachim.
      0558911f
    • Simon Peyton Jones's avatar
      Some refactoring of Demand and DmdAnal · 838da6fc
      Simon Peyton Jones authored
      This was authored by SPJ and extracted from the "Improve the handling of
      used-once stuff" patch by Joachim.
      838da6fc
  20. 09 Dec, 2013 3 commits
    • Joachim Breitner's avatar
      Replace mkTopDmdType by mkClosedStrictSig · 3cdf1251
      Joachim Breitner authored
      because it is not a top deman (see previous commit), and it is only used
      in an argument to mkStrictSig.
      3cdf1251
    • Joachim Breitner's avatar
      Rename topDmdType to nopDmdType · f64cf134
      Joachim Breitner authored
      because topDmdType is ''not'' the top of the lattice, as it puts an
      implicit absent demand on free variables, but Abs is the bottom of the
      Usage lattice.
      
      Why nopDmdType? Becuase it is the demand of doing nothing: Everything
      lazy, everything absent, no definite divergence.
      f64cf134
    • Joachim Breitner's avatar
      Do not forget CPR information after an IO action · a31cb5b0
      Joachim Breitner authored
      but do forget about certain divergence, if required. Fixes one part of
      ticket #8598.
      
      The added function (deferAfterIO) can maybe be merged with existing
      code, but given the ongoing work in the nested-cpr branch, I defer that
      work.
      a31cb5b0
  21. 04 Dec, 2013 1 commit
  22. 02 Dec, 2013 2 commits
  23. 01 Oct, 2013 2 commits
    • Gabor Greif's avatar
      Typos in comments · d6ccea98
      Gabor Greif authored
      d6ccea98
    • Simon Peyton Jones's avatar
      Lift an unnecessary assumption in the demand analyser (fix Trac #8329) · 9bd36664
      Simon Peyton Jones authored
      Here's the Note about the (simple) fix.  Apparently #8329 prevented all
      23 packages of the Snap framework from compiling.
      
      Note [Demand transformer for a ditionary selector]
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      If we evaluate (op dict-expr) under demand 'd', then we can push the demand 'd'
      into the appropriate field of the dictionary. What *is* the appropriate field?
      We just look at the strictness signature of the class op, which will be
      something like: U(AAASAAAAA).  Then replace the 'S' by the demand 'd'.
      
      For single-method classes, which are represented by newtypes the signature
      of 'op' won't look like U(...), so the splitProdDmd_maybe will fail.
      That's fine: if we are doing strictness analysis we are also doing inling,
      so we'll have inlined 'op' into a cast.  So we can bale out in a conservative
      way, returning topDmdType.
      
      It is (just.. Trac #8329) possible to be running strictness analysis *without*
      having inlined class ops from single-method classes.  Suppose you are using
      ghc --make; and the first module has a local -O0 flag.  So you may load a class
      without interface pragmas, ie (currently) without an unfolding for the class
      ops.   Now if a subsequent module in the --make sweep has a local -O flag
      you might do strictness analysis, but there is no inlining for the class op.
      This is wierd so I'm not worried about whether this optimises brilliantly; but
      it should not fall over.
      9bd36664