Skip to content
Snippets Groups Projects
  1. Mar 10, 2021
    • 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
    • Ryan Scott's avatar
      Fix some warnings when bootstrapping with GHC 9.0 · e9189745
      Ryan Scott authored and Marge Bot's avatar Marge Bot committed
      This fixes two classes of warnings that appear when bootstrapping with GHC 9.0:
      
      * `ghc-boot.cabal` was using `cabal-version: >=1.22`, which `cabal-install-3.4`
        now warns about, instead recommending the use of `cabal-version: 1.22`.
      * Several pattern matches were producing `Pattern match(es) are non-exhaustive`
        because of incorrect CPP. The pattern-match coverage checker _did_ become
        smarter in GHC 9.1, however, so I ended up needing to keep the CPP, adjusting
        them to use `#if __GLASGOW_HASKELL__ < 901` instead.
      e9189745
    • 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
    • Vladislav Zavialov's avatar
      Replace Ord TyLit with nonDetCmpTyLit (#19441) · aaa5fc21
      Vladislav Zavialov authored and Marge Bot's avatar Marge Bot committed
      The Ord instance was non-deterministic, but it's easy assume that it is
      deterministic. In fact, haddock-api used to do exactly that
      before haddock/7e8c7c3491f3e769368b8e6c767c62a33e996c80
      aaa5fc21
    • Andreas Klebinger's avatar
      Add a distclean command to hadrian. · 7a728ca6
      Andreas Klebinger authored and Marge Bot's avatar Marge Bot committed
      Hadrian should behave well and not delete files created by configure
      with the clean command. With this patch hadrian now deletes the fs/mingw
      tarballs only with distclean.
      
      This fixes #19320. The main impact being that validate won't have to
      redownload the tarballs when re-run.
      7a728ca6
    • Ryan Scott's avatar
      Document operator sections' interaction with subsumption · 376427ec
      Ryan Scott authored and Marge Bot's avatar Marge Bot committed
      This resolves #19457 by making a note of breaking changes (introduced in
      GHC 9.2) to the way that GHC typechecks operator sections where the operator
      has nested `forall`s or contexts in its type signature.
      376427ec
    • Ryan Scott's avatar
      Require GHC 8.10 as the minimum compiler for bootstrapping · 0a709dd9
      Ryan Scott authored and Marge Bot's avatar Marge Bot committed
      Now that GHC 9.0.1 is released, it is time to drop support for bootstrapping
      with GHC 8.8, as we only support building with the previous two major GHC
      releases. As an added bonus, this allows us to remove several bits of CPP that
      are either always true or no longer reachable.
      0a709dd9
  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 06, 2021
  6. Mar 05, 2021
  7. Mar 03, 2021
    • Matthew Pickering's avatar
      IPE: Give all constructor and function tables locations · f943edb0
      Matthew Pickering authored
      During testing it was observed that quite a few info tables were not
      being given locations (due to not being assigned source locations,
      because they were not enclosed by a source note). We can at least give
      the module name and type for such closures even if no more accurate
      source information.
      
      Especially for constructors this helps find them in the STG dumps.
      f943edb0
    • Matthew Pickering's avatar
    • Matthew Pickering's avatar
      f121ffe4
    • Matthew Pickering's avatar
    • Matthew Pickering's avatar
      Add test for whereFrom# · db80a5cc
      Matthew Pickering authored
      db80a5cc
    • Matthew Pickering's avatar
      Add whereFrom and whereFrom# primop · 9087899e
      Matthew Pickering authored
      The `whereFrom` function provides a Haskell interface for using the
      information created by `-finfo-table-map`. Given a Haskell value, the
      info table address will be passed to the `lookupIPE` function in order
      to attempt to find the source location information for that particular closure.
      
      At the moment it's not possible to distinguish the absense of the map
      and a failed lookup.
      9087899e
    • Matthew Pickering's avatar
      Add option to give each usage of a data constructor its own info table · a7aac008
      Matthew Pickering authored
      The `-fdistinct-constructor-tables` flag will generate a fresh info
      table for the usage of any data constructor. This is useful for
      debugging as now by inspecting the info table, you can determine which
      usage of a constructor caused that allocation rather than the old
      situation where the info table always mapped to the definition site of
      the data constructor which is useless.
      
      In conjunction with `-hi` and `-finfo-table-map` this gives a more fine
      grained understanding of where constructor allocations arise from in a
      program.
      a7aac008
    • 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
Loading