Skip to content
Snippets Groups Projects
  1. Mar 10, 2021
    • Joachim Breitner's avatar
      Use GHC2021 as default language · 115cd3c8
      Joachim Breitner authored and Ben Gamari's avatar Ben Gamari committed
      115cd3c8
    • Luke Lau's avatar
      template-haskell: Add putDoc, getDoc, withDecDoc and friends · 8a59f49a
      Luke Lau authored and Ben Gamari's avatar Ben Gamari committed
      This adds two new methods to the Quasi class, putDoc and getDoc. They
      allow Haddock documentation to be added to declarations, module headers,
      function arguments and class/type family instances, as well as looked
      up.
      
      It works by building up a map of names to attach pieces of
      documentation to, which are then added in the extractDocs function in
      GHC.HsToCore.Docs. However because these template haskell names need to
      be resolved to GHC names at the time they are added, putDoc cannot
      directly add documentation to declarations that are currently being
      spliced. To remedy this, withDecDoc/withDecsDoc wraps the operation with
      addModFinalizer, and provides a more ergonomic interface for doing so.
      Similarly, the funD_doc, dataD_doc etc. combinators provide a more
      ergonomic interface for documenting functions and their arguments
      simultaneously.
      
      This also changes ArgDocMap to use an IntMap rather than an Map Int, for
      efficiency.
      
      Part of the work towards #5467
      8a59f49a
    • Ben Gamari's avatar
      Bump bytestring submodule to 0.11.1.0 · e687ba83
      Ben Gamari authored
      e687ba83
    • Adam Gundry's avatar
      Simplify shadowing of DuplicateRecordFields in GHCi (fixes #19314) · 5581e7b4
      Adam Gundry authored and Marge Bot's avatar Marge Bot committed
      Previously, defining fields with DuplicateRecordFields in GHCi lead to
      strange shadowing behaviour, whereby fields would (accidentally) not
      shadow other fields.  This simplifies things so that fields are shadowed
      in the same way whether or not DuplicateRecordFields is enabled.
      5581e7b4
    • Adam Gundry's avatar
      d095954b
    • Matthew Pickering's avatar
      rts: Gradually return retained memory to the OS · afc357d2
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      Related to #19381 #19359 #14702
      
      After a spike in memory usage we have been conservative about returning
      allocated blocks to the OS in case we are still allocating a lot and would
      end up just reallocating them. The result of this was that up to 4 * live_bytes
      of blocks would be retained once they were allocated even if memory usage ended up
      a lot lower.
      
      For a heap of size ~1.5G, this would result in OS memory reporting 6G which is
      both misleading and worrying for users.
      In long-lived server applications this results in consistent high memory
      usage when the live data size is much more reasonable (for example ghcide)
      
      Therefore we have a new (2021) strategy which starts by retaining up to 4 * live_bytes
      of blocks before gradually returning uneeded memory back to the OS on subsequent
      major GCs which are NOT caused by a heap overflow.
      
      Each major GC which is NOT caused by heap overflow increases the consec_idle_gcs
      counter and the amount of memory which is retained is inversely proportional to this number.
      By default the excess memory retained is
       oldGenFactor (controlled by -F) / 2 ^ (consec_idle_gcs * returnDecayFactor)
      
      On a major GC caused by a heap overflow, the `consec_idle_gcs` variable is reset to 0
      (as we could continue to allocate more, so retaining all the memory might make sense).
      
      Therefore setting bigger values for `-Fd` makes the rate at which memory is returned slower.
      Smaller values make it get returned faster. Setting `-Fd0` disables the
      memory return completely, which is the behaviour of older GHC versions.
      
      The default is `-Fd4` which results in the following scaling:
      
      > mapM print [(x, 1/ (2**(x / 4))) | x <- [1 :: Double ..20]]
      (1.0,0.8408964152537146)
      (2.0,0.7071067811865475)
      (3.0,0.5946035575013605)
      (4.0,0.5)
      (5.0,0.4204482076268573)
      (6.0,0.35355339059327373)
      (7.0,0.29730177875068026)
      (8.0,0.25)
      (9.0,0.21022410381342865)
      (10.0,0.17677669529663687)
      (11.0,0.14865088937534013)
      (12.0,0.125)
      (13.0,0.10511205190671433)
      (14.0,8.838834764831843e-2)
      (15.0,7.432544468767006e-2)
      (16.0,6.25e-2)
      (17.0,5.255602595335716e-2)
      (18.0,4.4194173824159216e-2)
      (19.0,3.716272234383503e-2)
      (20.0,3.125e-2)
      
      So after 13 consecutive GCs only 0.1 of the maximum memory used will be retained.
      
      Further to this decay factor, the amount of memory we attempt to retain is
      also influenced by the GC strategy for the oldest generation. If we are using
      a copying strategy then we will need at least 2 * live_bytes for copying to take
      place, so we always keep that much. If using compacting or nonmoving then we need a lower number,
      so we just retain at least `1.2 * live_bytes` for some protection.
      
      In future we might want to make this behaviour more aggressive, some
      relevant literature is
      
      > Ulan Degenbaev, Jochen Eisinger, Manfred Ernst, Ross McIlroy, and Hannes Payer. 2016. Idle time garbage collection scheduling. SIGPLAN Not. 51, 6 (June 2016), 570–583. DOI:https://doi.org/10.1145/2980983.2908106
      
      which describes the "memory reducer" in the V8 javascript engine which
      on an idle collection immediately returns as much memory as possible.
      afc357d2
  2. Mar 09, 2021
    • Vladislav Zavialov's avatar
      Location for tuple section pattern error (#19504) · df8e8ba2
      Vladislav Zavialov authored and Marge Bot's avatar Marge Bot committed
      This fixes a regression that led to loss of location information
      in error messages about the use of tuple sections in patterns.
      df8e8ba2
    • Simon Peyton Jones's avatar
      Fixes to dealing with the export of main · 8fe274e2
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      It's surprisingly tricky to deal with 'main' (#19397). This
      patch does quite bit of refactoring do to it right. Well,
      more-right anyway!
      
      The moving parts are documented in GHC.Tc.Module
         Note [Dealing with main]
      
      Some other oddments:
      
      * Rename tcRnExports to rnExports; no typechecking here!
      
      * rnExports now uses checkNoErrs rather than failIfErrsM;
        the former fails only if rnExports itself finds errors
      
      * Small improvements to tcTyThingCategory, which ultimately
        weren't important to the patch, but I've retained as
        a minor improvement.
      8fe274e2
  3. Mar 08, 2021
  4. Mar 07, 2021
    • Ben Gamari's avatar
      Implement BoxedRep proposal · 3e082f8f
      Ben Gamari authored
      This implements the BoxedRep proposal, refactoring the `RuntimeRep`
      hierarchy from:
      
      ```haskell
      data RuntimeRep = LiftedPtrRep | UnliftedPtrRep | ...
      ```
      
      to
      
      ```haskell
      data RuntimeRep = BoxedRep Levity | ...
      data Levity = Lifted | Unlifted
      ```
      
      Updates binary, haddock submodules.
      
      Closes #17526.
      
      Metric Increase:
          T12545
      3e082f8f
    • Shayne Fletcher's avatar
      Implement record dot syntax · cf65cf16
      Shayne Fletcher authored and Ben Gamari's avatar Ben Gamari committed
      cf65cf16
  5. Mar 05, 2021
  6. Mar 03, 2021
    • Matthew Pickering's avatar
      Add test for whereFrom# · db80a5cc
      Matthew Pickering authored
      db80a5cc
    • Matthew Pickering's avatar
      Add -finfo-table-map which maps info tables to source positions · 4b297979
      Matthew Pickering authored
      This new flag embeds a lookup table from the address of an info table
      to information about that info table.
      
      The main interface for consulting the map is the `lookupIPE` C function
      
      > InfoProvEnt * lookupIPE(StgInfoTable *info)
      
      The `InfoProvEnt` has the following structure:
      
      > typedef struct InfoProv_{
      >     char * table_name;
      >     char * closure_desc;
      >     char * ty_desc;
      >     char * label;
      >     char * module;
      >     char * srcloc;
      > } InfoProv;
      >
      > typedef struct InfoProvEnt_ {
      >     StgInfoTable * info;
      >     InfoProv prov;
      >     struct InfoProvEnt_ *link;
      > } InfoProvEnt;
      
      The source positions are approximated in a similar way to the source
      positions for DWARF debugging information. They are only approximate but
      in our experience provide a good enough hint about where the problem
      might be. It is therefore recommended to use this flag in conjunction
      with `-g<n>` for more accurate locations.
      
      The lookup table is also emitted into the eventlog when it is available
      as it is intended to be used with the `-hi` profiling mode.
      
      Using this flag will significantly increase the size of the resulting
      object file but only by a factor of 2-3x in our experience.
      4b297979
    • Sebastian Graf's avatar
      DmdAnal: Better syntax for demand signatures (#19016) · 3630b9ba
      Sebastian Graf authored and Marge Bot's avatar Marge Bot committed
      The update of the Outputable instance resulted in a slew of
      documentation changes within Notes that used the old syntax.
      The most important doc changes are to `Note [Demand notation]`
      and the user's guide.
      
      Fixes #19016.
      3630b9ba
    • Matthew Pickering's avatar
      Profiling: Allow heap profiling to be controlled dynamically. · d89deeba
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      This patch exposes three new functions in `GHC.Profiling` which allow
      heap profiling to be enabled and disabled dynamically.
      
      1. startHeapProfTimer - Starts heap profiling with the given RTS options
      2. stopHeapProfTimer  - Stops heap profiling
      3. requestHeapCensus  - Perform a heap census on the next context
                              switch, regardless of whether the timer is enabled or not.
      d89deeba
    • Sylvain Henry's avatar
      Fix array and cleanup conversion primops (#19026) · d8dc0f96
      Sylvain Henry authored and Marge Bot's avatar Marge Bot committed
      The first change makes the array ones use the proper fixed-size types,
      which also means that just like before, they can be used without
      explicit conversions with the boxed sized types. (Before, it was Int# /
      Word# on both sides, now it is fixed sized on both sides).
      
      For the second change, don't use "extend" or "narrow" in some of the
      user-facing primops names for conversions.
      
        - Names like `narrowInt32#` are misleading when `Int` is 32-bits.
      
        - Names like `extendInt64#` are flat-out wrong when `Int is
          32-bits.
      
        - `narrow{Int,Word}<N>#` however map a type to itself, and so don't
          suffer from this problem. They are left as-is.
      
      These changes are batched together because Alex happend to use the array
      ops. We can only use released versions of Alex at this time, sadly, and
      I don't want to have to have a release thatwon't work for the final GHC
      9.2. So by combining these we get all the changes for Alex done at once.
      
      Bump hackage state in a few places, and also make that workflow slightly
      easier for the future.
      
      Bump minimum Alex version
      
      Bump Cabal, array, bytestring, containers, text, and binary submodules
      d8dc0f96
    • Daniel Winograd-Cort's avatar
      Add cmpNat, cmpSymbol, and cmpChar · eea96042
      Daniel Winograd-Cort authored and Marge Bot's avatar Marge Bot committed
      Add Data.Type.Ord
      Add and update tests
      Metric Increase:
          MultiLayerModules
      eea96042
  7. Mar 02, 2021
  8. Mar 01, 2021
    • Sebastian Graf's avatar
      Pmc: Implement `considerAccessible` (#18610) · e571eda7
      Sebastian Graf authored and Marge Bot's avatar Marge Bot committed
      Consider (`T18610`):
      ```hs
        f :: Bool -> Int
        f x = case (x, x) of
          (True,  True)  -> 1
          (False, False) -> 2
          (True,  False) -> 3 -- Warning: Redundant
      ```
      The third clause will be flagged as redundant. Nevertheless, the
      programmer might intend to keep the clause in order to avoid bitrot.
      
      After this patch, the programmer can write
      ```hs
        g :: Bool -> Int
        g x = case (x, x) of
          (True,  True)  -> 1
          (False, False) -> 2
          (True,  False) | GHC.Exts.considerAccessible -> 3 -- No warning
      ```
      And won't be bothered any longer. See also `Note [considerAccessible]`
      and the updated entries in the user's guide.
      
      Fixes #18610 and #19228.
      e571eda7
    • Alan Zimmerman's avatar
      Wrap LHsContext in Maybe in the GHC AST · ce85cffc
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      If the context is missing it is captured as Nothing, rather than
      putting a noLoc in the ParsedSource.
      
      Updates haddock submodule
      ce85cffc
    • Simon Peyton Jones's avatar
      Fix terrible occurrence-analysis bug · 6429943b
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      Ticket #19360 showed up a terrible bug in the occurrence analyser,
      in a situation like this
      
         Rec { f = g
             ; g = ..f...
               {-# RULE g .. = ...f... #-}  }
      
      Then f was postInlineUnconditionally, but not in the RULE (which
      is simplified first), so we had a RULE mentioning a variable that
      was not in scope.
      
      This led me to review (again) the subtle loop-breaker stuff in the
      occurrence analyser. The actual changes are few, and are largely
      simplifications.  I did a /lot/ of comment re-organising though.
      
      There was an unexpected amount of fallout.
      
      * Validation failed when compiling the stage2 compiler with profiling
        on. That turned to tickle a second latent bug in the same OccAnal
        code (at least I think it was always there), which led me to
        simplify still further; see Note [inl_fvs] in GHC.Core.Opt.OccurAnal.
      
      * But that in turn let me to some strange behaviour in CSE when ticks
        are in the picture, which I duly fixed.  See Note [Dealing with ticks]
        in GHC.Core.Opt.CSE.
      
      * Then I got an ASSERT failure in CoreToStg, which again seems to be
        a latent bug.  See Note [Ticks in applications] in GHC.CoreToStg
      
      * I also made one unforced change: I now simplify the RHS of a RULE in
        the same way as the RHS of a stable unfolding. This can allow a
        trivial binding to disappear sooner than otherwise, and I don't
        think it has any downsides.  The change is in
        GHC.Core.Opt.Simplify.simplRules.
      6429943b
    • Krzysztof Gogolewski's avatar
      Infer multiplicity in case expressions · 3b79e8b8
      Krzysztof Gogolewski authored and Marge Bot's avatar Marge Bot committed
      This is a first step towards #18738.
      3b79e8b8
    • Simon Peyton Jones's avatar
      Unify result type earlier to improve error messages · 7730713b
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      Ticket #19364 helpfully points out that we do not currently take
      advantage of pushing the result type of an application into the
      arguments.  This makes error messages notably less good.
      
      The fix is rather easy: move the result-type unification step earlier.
      It's even a bit more efficient; in the the checking case we now
      do one less zonk.
      
      See Note [Unify with expected type before typechecking arguments]
      in GHC.Tc.Gen.App
      
      This change generally improves error messages, but it made one worse:
      typecheck/should_fail/T16204c. That led me to the realisation that
      a good error can be replaced by a less-good one, which provoked
      me to change GHC.Tc.Solver.Interact.inertsCanDischarge.  It's
      explained in the new Note [Combining equalities]
      
      One other refactoring: I discovered that KindEqOrigin didn't need a
      Maybe in its type -- a nice simplification.
      7730713b
    • Sebastian Graf's avatar
      Widen acceptance window of `MultiLayerModules` (#19293) [skip ci] · 8c425bd8
      Sebastian Graf authored and Marge Bot's avatar Marge Bot committed
      As #19293 realises, this one keeps on flip flopping by 2.5%
      depending on how many modules there are within the GHC package.
      
      We should revert this once we figured out how to fix what's going on.
      8c425bd8
  9. Feb 28, 2021
    • Sebastian Graf's avatar
      CPR analysis: Use CPR of scrutinee for Case Binder CPR (#19232) · df2eca94
      Sebastian Graf authored and Marge Bot's avatar Marge Bot committed
      For years we have lived in a supposedly sweet spot that gave case
      binders the CPR property, unconditionally. Which is an optimistic hack
      that is now described in `Historical Note [Optimistic case binder CPR]`.
      
      In #19232 the concern was raised that this might do more harm than good
      and that might be better off simply by taking the CPR property of the
      scrutinee for the CPR type of the case binder. And indeed that's what we
      do now.
      
      Since `Note [CPR in a DataAlt case alternative]` is now only about field
      binders, I renamed and garbage collected it into
      `Note [Optimistic field binder CPR]`.
      
      NoFib approves:
      ```
      NoFib Results
      
      --------------------------------------------------------------------------------
              Program         Allocs    Instrs
      --------------------------------------------------------------------------------
                 anna          +0.1%     +0.1%
             nucleic2          -1.2%     -0.6%
                sched           0.0%     +0.9%
            transform          -0.0%     -0.1%
      --------------------------------------------------------------------------------
                  Min          -1.2%     -0.6%
                  Max          +0.1%     +0.9%
       Geometric Mean          -0.0%     +0.0%
      ```
      
      Fixes #19232.
      df2eca94
    • Sebastian Graf's avatar
      Widen acceptance window of T12545 (#19414) · 856929a5
      Sebastian Graf authored and Marge Bot's avatar Marge Bot committed
      This test flip-flops by +-1% in arbitrary changes in CI.
      While playing around with `-dunique-increment`, I could reproduce
      variations of 3% in compiler allocations, so I set the acceptance window
      accordingly.
      
      Fixes #19414.
      856929a5
    • Krzysztof Gogolewski's avatar
      Fix assertion error with linear types, #19400 · b8d40af1
      Krzysztof Gogolewski authored and Marge Bot's avatar Marge Bot committed
      The previous code using TyCoMapper could promote the same metavar twice.
      Use a set instead.
      b8d40af1
  10. Feb 27, 2021
Loading