Skip to content
Snippets Groups Projects
  1. Apr 21, 2024
  2. Apr 20, 2024
  3. Apr 19, 2024
    • Alan Zimmerman's avatar
      EPA: Fix span for PatBuilderAppType · 26036f96
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      Include the location of the prefix @ in the span for InVisPat.
      
      Also removes unnecessary annotations from HsTP.
      
      Contributes to #24669
      26036f96
    • Alan Zimmerman's avatar
      EPA: Provide correct span for PatBind · c90c6039
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      And remove unused parameter in checkPatBind
      
      Contributes to #24669
      c90c6039
    • Alan Zimmerman's avatar
      EPA: Fix comments in mkListSyntaxTy0 · f0701585
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      Also extend the test to confirm.
      
      Addresses #24669, 1 of 4
      f0701585
    • Simon Peyton Jones's avatar
      Do not float HNFs out of lambdas · 55a9d699
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      This MR adjusts SetLevels so that it is less eager to float a
      HNF (lambda or constructor application) out of a lambda, unless
      it gets to top level.
      
      Data suggests that this change is a small net win:
       * nofib bytes-allocated falls by -0.09% (but a couple go up)
       * perf/should_compile bytes-allocated falls by -0.5%
       * perf/should_run bytes-allocated falls by -0.1%
      See !12410 for more detail.
      
      When fiddling elsewhere, I also found that this patch had a huge
      positive effect on the (very delicate) test
        perf/should_run/T21839r
      But that improvement doesn't show up in this MR by itself.
      
      Metric Decrease:
          MultiLayerModulesRecomp
          T15703
          parsing001
      55a9d699
  4. Apr 17, 2024
  5. Apr 15, 2024
  6. Apr 12, 2024
    • Simon Peyton Jones's avatar
      Don't generate wrappers for `type data` constructors with StrictData · 5e4f4ba8
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      
      Previously, the logic for checking if a data constructor needs a wrapper or not
      would take into account whether the constructor's fields have explicit
      strictness (e.g., `data T = MkT !Int`), but the logic would _not_ take into
      account whether `StrictData` was enabled. This meant that something like `type
      data T = MkT Int` would incorrectly generate a wrapper for `MkT` if
      `StrictData` was enabled, leading to the horrible errors seen in #24620. To fix
      this, we disable generating wrappers for `type data` constructors altogether.
      
      Fixes #24620.
      
      Co-authored-by: default avatarRyan Scott <ryan.gl.scott@gmail.com>
      5e4f4ba8
    • Oleg Grenrus's avatar
      FastString is a __Modified__ UTF-8 · 0255d03c
      Oleg Grenrus authored and Marge Bot's avatar Marge Bot committed
      0255d03c
    • Zubin's avatar
      driver: Make `checkHomeUnitsClosed` faster · a933aff3
      Zubin authored and Marge Bot's avatar Marge Bot committed
      The implementation of `checkHomeUnitsClosed` was traversing every single path
      in the unit dependency graph - this grows exponentially and quickly grows to be
      infeasible on larger unit dependency graphs.
      
      Instead we replace this with a faster implementation which follows from the
      specificiation of the closure property - there is a closure error if there are
      units which are both are both (transitively) depended upon by home units and
      (transitively) depend on home units, but are not themselves home units.
      
      To compute the set of units required for closure, we first compute the closure
      of the unit dependency graph, then the transpose of this closure, and find all
      units that are reachable from the home units in the transpose of the closure.
      a933aff3
  7. Apr 10, 2024
    • Alan Zimmerman's avatar
      EPA: Remove unnecessary XRec in CompleteMatchSig · 1b1a92bd
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      The XRec for [LIdP pass] is not needed for exact printing, remove it.
      1b1a92bd
    • Rodrigo Mesquita's avatar
      Use symbol cache in internal interpreter too · 12931698
      Rodrigo Mesquita authored and Marge Bot's avatar Marge Bot committed
      This commit makes the symbol cache that was used by the external
      interpreter available for the internal interpreter too.
      
      This follows from the analysis in #23415 that suggests the internal
      interpreter could benefit from this cache too, and that there is no good
      reason not to have the cache for it too. It also makes it a bit more
      uniform to have the symbol cache range over both the internal and
      external interpreter.
      
      This commit also refactors the cache into a function which is used by
      both `lookupSymbol` and also by `lookupSymbolInDLL`, extending the
      caching logic to `lookupSymbolInDLL` too.
      12931698
    • Alexis King's avatar
      linker: Avoid linear search when looking up Haskell symbols via dlsym · e008a19a
      Alexis King authored and Marge Bot's avatar Marge Bot committed
      
      See the primary Note [Looking up symbols in the relevant objects] for a
      more in-depth explanation.
      
      When dynamically loading a Haskell symbol (typical when running a splice or
      GHCi expression), before this commit we would search for the symbol in
      all dynamic libraries that were loaded. However, this could be very
      inefficient when too many packages are loaded (which can happen if there are
      many package dependencies) because the time to lookup the would be
      linear in the number of packages loaded.
      
      This commit drastically improves symbol loading performance by
      introducing a mapping from units to the handles of corresponding loaded
      dlls. These handles are returned by dlopen when we load a dll, and can
      then be used to look up in a specific dynamic library.
      
      Looking up a given Name is now much more precise because we can get
      lookup its unit in the mapping and lookup the symbol solely in the
      handles of the dynamic libraries loaded for that unit.
      
      In one measurement, the wait time before the expression was executed
      went from +-38 seconds down to +-2s.
      
      This commit also includes Note [Symbols may not be found in pkgs_loaded],
      explaining the fallback to the old behaviour in case no dll can be found
      in the unit mapping for a given Name.
      
      Fixes #23415
      
      Co-authored-by: default avatarRodrigo Mesquita <(@alt-romes)>
      e008a19a
    • Jade's avatar
      Validate -main-is flag using parseIdentifier · 3d0806fc
      Jade authored and Marge Bot's avatar Marge Bot committed
      Fixes #24368
      3d0806fc
  8. Apr 09, 2024
  9. Apr 08, 2024
    • Alan Zimmerman's avatar
      EPA: Move DeltaPos and EpaLocation' into GHC.Types.SrcLoc · 12b997df
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      This allows us to use a NoCommentsLocation for the possibly trailing
      comma location in a StringLiteral.
      This in turn allows us to correctly roundtrip via makeDeltaAst.
      12b997df
    • Alan Zimmerman's avatar
      EPA: Use EpaLocation in WarningTxt · 3b7b0c1c
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      This allows us to use an EpDelta if needed when using makeDeltaAst.
      3b7b0c1c
    • Hannes Siebenhandl's avatar
      Eliminate name thunk in declaration fingerprinting · fbb91a63
      Hannes Siebenhandl authored and Marge Bot's avatar Marge Bot committed
      Thunk analysis showed that we have about 100_000 thunks (in agda and
      `-fwrite-simplified-core`) pointing to the name of the name decl.
      Forcing this thunk fixes this issue.
      
      The thunk created here is retained by the thunk created by forkM, it is
      better to eagerly force this because the result (a `Name`) is already
      retained indirectly via the `IfaceDecl`.
      fbb91a63
    • Hannes Siebenhandl's avatar
      Never UNPACK `FastMutInt` for counting z-encoded `FastString`s · f2cc1107
      Hannes Siebenhandl authored and Marge Bot's avatar Marge Bot committed
      In `FastStringTable`, we count the number of z-encoded FastStrings
      that exist in a GHC session.
      We used to UNPACK the counters to not waste memory, but live retainer
      analysis showed that we allocate a lot of `FastMutInt`s, retained by
      `mkFastZString`.
      
      We lazily compute the `FastZString`, only incrementing the counter when the `FastZString` is
      forced.
      The function `mkFastStringWith` calls `mkZFastString` and boxes the
      `FastMutInt`, leading to the following core:
      
          mkFastStringWith
            = \ mk_fs _  ->
                   = case stringTable of
                      { FastStringTable _ n_zencs segments# _ ->
                          ...
                               case ((mk_fs (I# ...) (FastMutInt n_zencs))
                                  `cast` <Co:2> :: ...)
                                  ...
      
      Marking this field as `NOUNPACK` avoids this reboxing, eliminating the
      allocation of a fresh `FastMutInt` on every `FastString` allocation.
      f2cc1107
    • Hannes Siebenhandl's avatar
      Avoid UArray when indexing is not required · 88cb3e10
      Hannes Siebenhandl authored and Marge Bot's avatar Marge Bot committed
      `UnlinkedBCO`'s can occur many times in the heap. Each `UnlinkedBCO`
      references two `UArray`'s but never indexes them. They are only needed
      to encode the elements into a `ByteArray#`. The three words for
      the lower bound, upper bound and number of elements are essentially
      unused, thus we replace `UArray` with a wrapper around `ByteArray#`.
      This saves us up to three words for each `UnlinkedBCO`.
      
      Further, to avoid re-allocating these words for `ResolvedBCO`, we repeat
      the procedure for `ResolvedBCO` and add custom `Binary` and `Show` instances.
      
      For example, agda's repl session has around 360_000 UnlinkedBCO's,
      so avoiding these three words is already saving us around 8MB residency.
      88cb3e10
  10. Apr 05, 2024
  11. Apr 04, 2024
    • Matthew Pickering's avatar
      Fix off by one error in seekBinNoExpand and seekBin · 28009fbc
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      28009fbc
    • Andrei Borzenkov's avatar
      Change how invisible patterns represented in haskell syntax and TH AST (#24557) · 36a75b80
      Andrei Borzenkov authored and Marge Bot's avatar Marge Bot committed
      Before this patch:
        data ArgPat p
          = InvisPat (LHsType p)
          | VisPat (LPat p)
      
      With this patch:
        data Pat p
          = ...
          | InvisPat (LHsType p)
          ...
      
      And the same transformation in the TH land. The rest of the
      changes is just updating code to handle new AST and writing tests
      to check if it is possible to create invalid states using TH.
      
      Metric Increase:
          MultiLayerModulesTH_OneShot
      36a75b80
    • Hannes Siebenhandl's avatar
      Compact FlatBag array representation · 82cfe10c
      Hannes Siebenhandl authored and Marge Bot's avatar Marge Bot committed
      `Array` contains three additional `Word`'s we do not need in `FlatBag`. Move
      `FlatBag` to `SmallArray`.
      
      Expand the API of SmallArray by `sizeofSmallArray` and add common
      traversal functions, such as `mapSmallArray` and `foldMapSmallArray`.
      Additionally, allow users to force the elements of a `SmallArray`
      via `rnfSmallArray`.
      82cfe10c
    • Hannes Siebenhandl's avatar
      Replace `SizedSeq` with `FlatBag` for flattened structure · 5f085d3a
      Hannes Siebenhandl authored and Marge Bot's avatar Marge Bot committed
      LinkedLists are notoriously memory ineffiecient when all we do is
      traversing a structure.
      As 'UnlinkedBCO' has been identified as a data structure that impacts
      the overall memory usage of GHCi sessions, we avoid linked lists and
      prefer flattened structure for storing.
      
      We introduce a new memory efficient representation of sequential
      elements that has special support for the cases:
      
      * Empty
      * Singleton
      * Tuple Elements
      
      This improves sharing in the 'Empty' case and avoids the overhead of
      'Array' until its constant overhead is justified.
      5f085d3a
    • Luite Stegeman's avatar
      Update correct counter in bumpTickyAllocd · 0c4a9686
      Luite Stegeman authored and Marge Bot's avatar Marge Bot committed
      0c4a9686
Loading