1. 26 Apr, 2018 1 commit
    • Simon Peyton Jones's avatar
      Do not unpack class dictionaries with INLINABLE · 3d38e828
      Simon Peyton Jones authored
      Matthew Pickering uncovered a bad performance hole in the way
      that single-method dictionaries work, described in Trac #14955.
      
      See Note [Do not unpack class dictionaries] in WwLib.
      
      I tried to fix this 6 years ago, but got it slightly wrong.  This patch
      fixes it, which makes a dramatic improvement in the test case.
      
      Nofib highlights: not much happening:
      
        Program           Size    Allocs   Runtime   Elapsed  TotalMem
      -----------------------------------------------------------------
            VSM          -0.3%     +2.7%     -7.4%     -7.4%      0.0%
      cacheprof          -0.0%     +0.1%     +0.3%     +0.7%      0.0%
        integer          -0.0%     +1.1%     +7.5%     +7.5%      0.0%
            tak          -0.1%     -0.2%     0.024     0.024      0.0%
      -----------------------------------------------------------------
            Min          -4.4%     -0.2%     -7.4%     -7.4%     -8.0%
            Max          +0.6%     +2.7%     +7.5%     +7.5%      0.0%
      Geom Mean          -0.1%     +0.0%     +0.1%     +0.1%     -0.2%
      
      I investigated VSM.  The patch unpacks class dictionaries a bit more
      than before (i.e. does so if there is no INLINABLE pragma). And that
      gives better code in VSM (less dictionary selection etc), but one closure
      gets one word bigger.
      
      I'll accept these changes in exchange for more robust performance.
      
      Some ghci.debugger output wobbled around (order of bindings
      being displayed). I have no idea why; but I accepted the changes.
      3d38e828
  2. 24 Apr, 2018 1 commit
  3. 20 Apr, 2018 2 commits
    • Tobias Dammers's avatar
      Remove unnecessary check in simplCast · 2a5bdd9a
      Tobias Dammers authored
      The coercion optimizer will take care of it anyway, and the check is
      prohibitively expensive.
      
      See Trac #14737.
      
      Reviewers: bgamari
      
      Subscribers: simonpj, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4568
      2a5bdd9a
    • Tobias Dammers's avatar
      Caching coercion roles in NthCo and coercionKindsRole refactoring · 2fbe0b51
      Tobias Dammers authored
      While addressing nonlinear behavior related to coercion roles,
      particularly `NthCo`, we noticed that coercion roles are recalculated
      often even though they should be readily at hand already in most cases.
      This patch adds a `Role` to the `NthCo` constructor so that we can cache
      them rather than having to recalculate them on the fly.
      https://ghc.haskell.org/trac/ghc/ticket/11735#comment:23 explains the
      approach.
      
      Performance improvement over GHC HEAD, when compiling Grammar.hs (see below):
      
      GHC 8.2.1:
      ```
      ghc Grammar.hs  176.27s user 0.23s system 99% cpu 2:56.81 total
      ```
      
      before patch (but with other optimizations applied):
      ```
      ghc Grammar.hs -fforce-recomp  175.77s user 0.19s system 100% cpu 2:55.78 total
      ```
      
      after:
      ```
      ../../ghc/inplace/bin/ghc-stage2 Grammar.hs  10.32s user 0.17s system 98% cpu 10.678 total
      ```
      
      Introduces the following regressions:
      
      - perf/compiler/parsing001 (possibly false positive)
      - perf/compiler/T9872
      - perf/compiler/haddock.base
      
      Reviewers: goldfire, bgamari, simonpj
      
      Reviewed By: simonpj
      
      Subscribers: rwbarton, thomie, carter
      
      GHC Trac Issues: #11735
      
      Differential Revision: https://phabricator.haskell.org/D4394
      2fbe0b51
  4. 13 Apr, 2018 1 commit
    • Alan Zimmerman's avatar
      TTG for HsBinds and Data instances Plan B · b1386942
      Alan Zimmerman authored
      Summary:
      - Add the balance of the TTG extensions for hsSyn/HsBinds
      
      - Move all the (now orphan) data instances into hsSyn/HsInstances and
      use TTG Data instances Plan B
      https://ghc.haskell.org/trac/ghc/wiki/ImplementingTreesThatGrow/Instances#PLANB
      
      Updates haddock submodule.
      
      Illustrative numbers
      
      Compiling HsInstances before using Plan B.
      
      Max residency ~ 5G
      <<ghc: 629,864,691,176 bytes, 5300 GCs,
             321075437/1087762592 avg/max bytes residency (23 samples),
             2953M in use, 0.000 INIT (0.000 elapsed),
             383.511 MUT (384.986 elapsed), 37.426 GC (37.444 elapsed) :ghc>>
      
      Using Plan B
      
      Max residency 1.1G
      
      <<ghc: 78,832,782,968 bytes, 2884 GCs,
             222140352/386470152 avg/max bytes residency (34 samples),
             1062M in use, 0.001 INIT (0.001 elapsed),
             56.612 MUT (62.917 elapsed), 32.974 GC (32.923 elapsed) :ghc>>
      
      Test Plan: ./validate
      
      Reviewers: shayan-najd, goldfire, bgamari
      
      Subscribers: goldfire, thomie, mpickering, carter
      
      Differential Revision: https://phabricator.haskell.org/D4581
      b1386942
  5. 09 Apr, 2018 1 commit
  6. 02 Apr, 2018 1 commit
    • Simon Peyton Jones's avatar
      SpecConstr: accommodate casts in value arguments · 5ab8094e
      Simon Peyton Jones authored
      This commit:
      
        commit fb050a33
        Author: Simon Peyton Jones <simonpj@microsoft.com>
        Date:   Thu Oct 12 11:00:19 2017 +0100
      
        Do not bind coercion variables in SpecConstr rules
      
      arranged to reject any SpecConstr call pattern that mentioned
      a coercion in the pattern.
      
      There was a good reason for that
      -- see Note [SpecConstr and casts] --
      but I didn't realise how important it was to accept patterns
      that mention casts in /terms/.  Trac #14936 showed this up.
      
      This patch just narrows the restriction to discard only
      the cases where the coercion is mentioned only in types.
      Fortunately that was pretty easy to do.
      5ab8094e
  7. 01 Apr, 2018 1 commit
    • Richard Eisenberg's avatar
      Track type variable scope more carefully. · faec8d35
      Richard Eisenberg authored
      The main job of this commit is to track more accurately the scope
      of tyvars introduced by user-written foralls. For example, it would
      be to have something like this:
      
        forall a. Int -> (forall k (b :: k). Proxy '[a, b]) -> Bool
      
      In that type, a's kind must be k, but k isn't in scope. We had a
      terrible way of doing this before (not worth repeating or describing
      here, but see the old tcImplicitTKBndrs and friends), but now
      we have a principled approach: make an Implication when kind-checking
      a forall. Doing so then hooks into the existing machinery for
      preventing skolem-escape, performing floating, etc. This also means
      that we bump the TcLevel whenever going into a forall.
      
      The new behavior is done in TcHsType.scopeTyVars, but see also
      TcHsType.tc{Im,Ex}plicitTKBndrs, which have undergone significant
      rewriting. There are several Notes near there to guide you. Of
      particular interest there is that Implication constraints can now
      have skolems that are out of order; this situation is reported in
      TcErrors.
      
      A major consequence of this is a slightly tweaked process for type-
      checking type declarations. The new Note [Use SigTvs in kind-checking
      pass] in TcTyClsDecls lays it out.
      
      The error message for dependent/should_fail/TypeSkolEscape has become
      noticeably worse. However, this is because the code in TcErrors goes to
      some length to preserve pre-8.0 error messages for kind errors. It's time
      to rip off that plaster and get rid of much of the kind-error-specific
      error messages. I tried this, and doing so led to a lovely error message
      for TypeSkolEscape. So: I'm accepting the error message quality regression
      for now, but will open up a new ticket to fix it, along with a larger
      error-message improvement I've been pondering. This applies also to
      dependent/should_fail/{BadTelescope2,T14066,T14066e}, polykinds/T11142.
      
      Other minor changes:
       - isUnliftedTypeKind didn't look for tuples and sums. It does now.
      
       - check_type used check_arg_type on both sides of an AppTy. But the left
         side of an AppTy isn't an arg, and this was causing a bad error message.
         I've changed it to use check_type on the left-hand side.
      
       - Some refactoring around when we print (TYPE blah) in error messages.
         The changes decrease the times when we do so, to good effect.
         Of course, this is still all controlled by
         -fprint-explicit-runtime-reps
      
      Fixes #14066 #14749
      
      Test cases: dependent/should_compile/{T14066a,T14749},
                  dependent/should_fail/T14066{,c,d,e,f,g,h}
      faec8d35
  8. 26 Mar, 2018 1 commit
    • alexvieth's avatar
      Fix performance of flattener patch (#12919) · b47a6c3a
      alexvieth authored
      This patch, authored by alexvieth and reviewed at D4451,
      makes performance improvements by critically optimizing parts
      of the flattener.
      
      Summary:
      T3064, T5321FD, T5321Fun, T9872a, T9872b, T9872c all pass.
      T9872a and T9872c show improvements beyond the -5% threshold.
      T9872d fails at 10.9% increased allocations.
      b47a6c3a
  9. 08 Mar, 2018 1 commit
  10. 07 Mar, 2018 1 commit
  11. 02 Mar, 2018 1 commit
    • niteria's avatar
      Cache the fingerprint of sOpt_P · b8f03bbe
      niteria authored
      Before this change we would compute a hash of
      all the command line -optP flags once per file.
      With a lot of files and many -optP flags, that's a lot
      of repeated work.
      
      I added a new Note that explains the approach and rationale.
      
      Test Plan: new test
      
      Reviewers: simonmar, simonpj, bgamari
      
      Reviewed By: simonpj
      
      Subscribers: rwbarton, thomie, carter
      
      GHC Trac Issues: #14697
      
      Differential Revision: https://phabricator.haskell.org/D4445
      b8f03bbe
  12. 01 Mar, 2018 1 commit
  13. 27 Feb, 2018 1 commit
    • Simon Peyton Jones's avatar
      Better stats for T5837 · d675a354
      Simon Peyton Jones authored
      I'm not sure why. It's an odd test, mind you; a weird type-function
      recursion thing.  So I'm not inclined to investigate.
      
      Anyway, good!
      d675a354
  14. 25 Feb, 2018 1 commit
  15. 20 Feb, 2018 1 commit
  16. 01 Feb, 2018 2 commits
    • Simon Peyton Jones's avatar
      Re-center improved perf for T3064 · db5a4b83
      Simon Peyton Jones authored
      There's a 6% reduction in allocation on T3064.  I think it's due to
      
        commit e4ab65bd
        Author: Tobias Dammers <tdammers@gmail.com>
        Date:   Wed Jan 31 21:39:45 2018 -0500
      
            Optimize coercionKind (Trac #11735)
      
      I'm not certain -- but, hey, it's good news
      db5a4b83
    • takano-akio's avatar
      Implement BlockArguments (#10843) · be84823b
      takano-akio authored
      This patch implements the BlockArguments extension, as proposed at
      https://github.com/ghc-proposals/ghc-proposals/pull/90. It also
      fixes #10855 as a side-effect.
      
      This patch adds a large number of shift-reduce conflicts to the parser.
      All of them concern the ambiguity as to where constructs like `if` and
      `let` end. Fortunately they are resolved correctly by preferring shift.
      
      The patch is based on @gibiansky's ArgumentDo implementation (D1219).
      
      Test Plan: ./validate
      
      Reviewers: goldfire, bgamari, alanz, mpickering
      
      Reviewed By: bgamari, mpickering
      
      Subscribers: Wizek, dfeuer, gibiansky, rwbarton, thomie, mpickering, carter
      
      GHC Trac Issues: #10843, #10855
      
      Differential Revision: https://phabricator.haskell.org/D4260
      be84823b
  17. 26 Jan, 2018 2 commits
  18. 23 Jan, 2018 1 commit
    • niteria's avatar
      Allocate less in plus_mod_dep · f00ddea9
      niteria authored
      This gives a 10% allocation improvement on MultiLayerModules.
      The idea is to reuse existing tuples, instead of constantly
      constructing new ones.
      
      Test Plan: ./validate
      
      Reviewers: simonpj, bgamari
      
      Reviewed By: simonpj, bgamari
      
      Subscribers: rwbarton, thomie, simonmar, carter
      
      Differential Revision: https://phabricator.haskell.org/D4332
      f00ddea9
  19. 21 Jan, 2018 1 commit
    • niteria's avatar
      Use IntSet in Dataflow · 88297438
      niteria authored
      Before this change, a list was used as a substitute for a heap.
      This led to quadratic behavior on a simple program (see new
      test case).
      
      This change replaces it with IntSet in effect reverting
      5a1a2633. @simonmar said it's fine to revert as long as nofib
      results are good.
      
      Test Plan:
      new test case:
      
      20% improvement
      3x improvement when N=10000
      
      nofib:
      
      I run it twice for before and after because the compile time
      results are noisy.
      
      - Compile Allocations:
      
      ```
                before    before re-run    after     after re-run
      -1 s.d.   -----     -0.0%            -0.1%     -0.1%
      +1 s.d.   -----     +0.0%            +0.1%     +0.1%
      Average   -----     +0.0%            -0.0%     -0.0%
      ```
      - Compile Time:
      
      ```
                before    before re-run    after     after re-run
      -1 s.d.   -----     -0.1%            -2.3%     -2.6%
      +1 s.d.   -----     +5.2%            +3.7%     +4.4%
      Average   -----     +2.5%            +0.7%     +0.8%
      
      ```
      I checked each case and couldn't find consistent slow-down/speed-up on
      compile time. Full results here: P173
      
      Reviewers: simonpj, simonmar, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: rwbarton, thomie, carter, simonmar
      
      GHC Trac Issues: #14667
      
      Differential Revision: https://phabricator.haskell.org/D4329
      88297438
  20. 10 Jan, 2018 1 commit
    • niteria's avatar
      Lift constructor tag allocation out of a loop · dbdf77d9
      niteria authored
      Before this change, for each constructor that we want
      to allocate a tag for we would traverse a list of all
      the constructors in a datatype to determine which tag
      a constructor should get.
      
      This is obviously quadratic and for datatypes with 10k
      constructors it actually makes a big difference.
      
      This change implements the plan outlined by @simonpj in
      https://mail.haskell.org/pipermail/ghc-devs/2017-October/014974.html
      which is basically about using a map and constructing it outside the
      loop.
      
      One place where things got a bit awkward was TysWiredIn.hs,
      it would have been possible to just assign the tags by hand, but
      that seemed error-prone to me, so I decided to go through a map
      there as well.
      
      Test Plan:
      ./validate
      On a file with 10k constructors
      Before:
         8,130,522,344 bytes allocated in the heap
        Total   time    3.682s  (  3.920s elapsed)
      After:
         4,133,478,744 bytes allocated in the heap
        Total   time    2.509s  (  2.750s elapsed)
      
      Reviewers: simonpj, bgamari
      
      Reviewed By: simonpj
      
      Subscribers: goldfire, rwbarton, thomie, simonmar, carter, simonpj
      
      GHC Trac Issues: #14657
      
      Differential Revision: https://phabricator.haskell.org/D4289
      dbdf77d9
  21. 04 Jan, 2018 1 commit
    • Simon Peyton Jones's avatar
      Drop dead Given bindings in setImplicationStatus · 954cbc7c
      Simon Peyton Jones authored
      Trac #13032 pointed out that we sometimes generate unused
      bindings for Givens, and (worse still) we can't always discard
      them later (we don't drop a case binding unless we can prove
      that the scrutinee is non-bottom.
      
      It looks as if this may be a major reason for the performace
      problems in #14338 (see comment:29).
      
      This patch fixes the problem at source, by pruning away all the
      dead Givens.  See Note [Delete dead Given evidence bindings]
      
      Remarkably, compiler allocation falls by 23% in
      perf/compiler/T12227!
      
      I have not confirmed whether this change actualy helps with
      954cbc7c
  22. 02 Jan, 2018 1 commit
    • Tamar Christina's avatar
      Windows: fix all failing tests. · 27b7b4db
      Tamar Christina authored
      This makes the testsuite pass clean on Windows again.
      It also fixes the `libstdc++-6.dll` error harbormaster
      was showing.
      
      I'm marking some tests as isolated tests to reduce their
      flakiness (mostly concurrency tests) when the test system
      is under heavy load.
      
      Updates process submodule.
      
      Test Plan: ./validate
      
      Reviewers: hvr, bgamari, erikd, simonmar
      
      Reviewed By: bgamari
      
      Subscribers: rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4277
      27b7b4db
  23. 13 Dec, 2017 1 commit
    • Simon Peyton Jones's avatar
      Re-centre perf for T5321Fun · 63e968a9
      Simon Peyton Jones authored
      Bytes allocated has fallen by around 5%. I think this due
      to some of my recent refactoring of the typechecker, but
      I'm not certain about exactly which change did it.
      
      Good though!
      63e968a9
  24. 21 Nov, 2017 1 commit
    • Ben Gamari's avatar
      Revert "trees that grow" work · 314bc314
      Ben Gamari authored
      As documented in #14490, the Data instances currently blow up
      compilation time by too much to stomach. Alan will continue working on
      this in a branch and we will perhaps merge to 8.2 before 8.2.1 to avoid
      having to perform painful cherry-picks in 8.2 minor releases.
      
      Reverts haddock submodule.
      
      This reverts commit 47ad6578.
      This reverts commit e3ec2e7a.
      This reverts commit 438dd1cb.
      This reverts commit 0ff152c9.
      314bc314
  25. 14 Nov, 2017 1 commit
  26. 11 Nov, 2017 1 commit
  27. 09 Nov, 2017 1 commit
    • Tamar Christina's avatar
      Update Win32 version for GHC 8.4. · bdd2d286
      Tamar Christina authored
      Update to Win32 2.6 which is the expected version release for 8.4
      
      This involves moving Cabal forward which brings some backwards incompatible
      changes that needs various fixups.
      
      Bump a bunch of submodules
      
      Test Plan: ./validate
      
      Reviewers: austin, bgamari, angerman
      
      Reviewed By: bgamari, angerman
      
      Subscribers: angerman, thomie, rwbarton
      
      Differential Revision: https://phabricator.haskell.org/D4133
      bdd2d286
  28. 08 Nov, 2017 1 commit
  29. 07 Nov, 2017 2 commits
  30. 06 Nov, 2017 1 commit
  31. 03 Nov, 2017 1 commit
  32. 25 Oct, 2017 2 commits
    • Tobias Dammers's avatar
      Factor out readField (#14364) · dbd81f7e
      Tobias Dammers authored
      Improves compiler performance of deriving Read instances, as suggested
      in the issue.
      
      Additionally, we introduce `readSymField`, a companion to `readField`
      that parses symbol-type fields (where the field name is a symbol, e.g.
      `(#)`, rather than an alphanumeric identifier. The decision between
      these two functions is made a compile time, because we already know
      which one we need based on the field name.
      
      Reviewers: austin, hvr, bgamari, RyanGlScott
      
      Reviewed By: bgamari
      
      Subscribers: RyanGlScott, rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D4108
      dbd81f7e
    • duog's avatar
      Fix space leak in BinIface.getSymbolTable · 1c15d8ed
      duog authored
      Replace a call to mapAccumR, which uses linear stack space, with a
      gadget that uses constant space.
      
      Remove an unused parameter from fromOnDiskName.
      
      The tests T1292_imports and T4239 are now reporting imported names in a
      different order. I don't completely understand why, but I presume it is
      because the symbol tables are now read more strictly. The new order
      seems better in T1792_imports, and equally random in T4239.
      
      There are several performance test improvements.
      
      Test Plan: ./validate
      
      Reviewers: austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: alexbiehl, rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D4124
      1c15d8ed
  33. 25 Sep, 2017 1 commit
    • Simon Peyton Jones's avatar
      Improve type-error reporting · 1b476ab5
      Simon Peyton Jones authored
      This patch does two things:
      
      * When reporting a hole, we now include its kind if the
        kind is not just '*'.  This addresses Trac #14265
      
      * When reporting things like "'a' is a rigid type varaible
        bound by ...", this patch arranges to group the type variables
        together, so we don't repeat the "bound by..." stuff endlessly
      1b476ab5
  34. 21 Sep, 2017 1 commit
  35. 09 Sep, 2017 1 commit