1. 18 Oct, 2020 1 commit
    • Dylan Yudaken's avatar
      When using rts_setInCallCapability, lock incall threads · 50e9df49
      Dylan Yudaken authored
      This diff makes sure that incall threads, when using `rts_setInCallCapability`, will be created as locked.
      If the thread is not locked, the thread might end up being scheduled to a different capability.
      While this is mentioned in the docs for `rts_setInCallCapability,`, it makes the method significantly less useful as there is no guarantees on the capability being used.
      This commit also adds a test to make sure things stay on the correct capability.
  2. 16 Oct, 2020 1 commit
  3. 09 Oct, 2020 2 commits
    • Sylvain Henry's avatar
      Expose RTS-only ways (#18651) · accdb24a
      Sylvain Henry authored
      Some RTS ways are exposed via settings (ghcThreaded, ghcDebugged) but
      not all. It's simpler if the RTS exposes them all itself.
    • Tamar Christina's avatar
      rts: fix race condition in StgCRun · fd984d68
      Tamar Christina authored
      On windows the stack has to be allocated 4k at a time, otherwise we get
      a segfault. This is done by using a helper ___chkstk_ms that is provided
      by libgcc. The Haskell side already knows how to handle this but we need
      to do the same from STG. Previously we would drop the stack in StgRun
      but would only make it valid whenever the scheduler loop ran.
      This approach was fundamentally broken in that it falls apart when you
      take a signal from the OS. We see it less often because you initially
      get allocated a 1MB stack block which you have to blow past first.
      Concretely this means we must always keep the stack valid.
      Fixes #18601.
  4. 30 Sep, 2020 2 commits
  5. 18 Sep, 2020 1 commit
    • Ben Gamari's avatar
      rts: Refactor foreign export tracking · c4921349
      Ben Gamari authored
      This avoids calling `libc` in the initializers which are responsible for
      registering foreign exports. We believe this should avoid the corruption
      observed in #18548.
      See Note [Tracking foreign exports] in rts/ForeignExports.c for an
      overview of the new scheme.
  6. 08 Sep, 2020 1 commit
  7. 20 Jul, 2020 4 commits
  8. 15 Jul, 2020 4 commits
  9. 07 Jul, 2020 4 commits
  10. 10 May, 2020 1 commit
  11. 11 Feb, 2020 1 commit
  12. 20 Nov, 2019 1 commit
    • roland's avatar
      Use pointer equality in Eq/Ord for ThreadId · d1f3c637
      roland authored
      Changes (==) to use only pointer equality. This is safe because two
      threads are the same iff they have the same id.
      Changes `compare` to check pointer equality first and fall back on ids
      only in case of inequality.
      See discussion in #16761.
  13. 26 Oct, 2019 1 commit
  14. 21 Oct, 2019 1 commit
    • Ben Gamari's avatar
      rts: Implement concurrent collection in the nonmoving collector · bd8e3ff4
      Ben Gamari authored
      This extends the non-moving collector to allow concurrent collection.
      The full design of the collector implemented here is described in detail
      in a technical note
          B. Gamari. "A Concurrent Garbage Collector For the Glasgow Haskell
          Compiler" (2018)
      This extension involves the introduction of a capability-local
      remembered set, known as the /update remembered set/, which tracks
      objects which may no longer be visible to the collector due to mutation.
      To maintain this remembered set we introduce a write barrier on
      mutations which is enabled while a concurrent mark is underway.
      The update remembered set representation is similar to that of the
      nonmoving mark queue, being a chunked array of `MarkEntry`s. Each
      `Capability` maintains a single accumulator chunk, which it flushed
      when it (a) is filled, or (b) when the nonmoving collector enters its
      post-mark synchronization phase.
      While the write barrier touches a significant amount of code it is
      conceptually straightforward: the mutator must ensure that the referee
      of any pointer it overwrites is added to the update remembered set.
      However, there are a few details:
       * In the case of objects with a dirty flag (e.g. `MVar`s) we can
         exploit the fact that only the *first* mutation requires a write
       * Weak references, as usual, complicate things. In particular, we must
         ensure that the referee of a weak object is marked if dereferenced by
         the mutator. For this we (unfortunately) must introduce a read
         barrier, as described in Note [Concurrent read barrier on deRefWeak#]
         (in `NonMovingMark.c`).
       * Stable names are also a bit tricky as described in Note [Sweeping
         stable names in the concurrent collector] (`NonMovingSweep.c`).
      We take quite some pains to ensure that the high thread count often seen
      in parallel Haskell applications doesn't affect pause times. To this end
      we allow thread stacks to be marked either by the thread itself (when it
      is executed or stack-underflows) or the concurrent mark thread (if the
      thread owning the stack is never scheduled). There is a non-trivial
      handshake to ensure that this happens without racing which is described
      in Note [StgStack dirtiness flags and concurrent marking].
      Co-Authored-by: Ömer Sinan Ağacan's avatarÖmer Sinan Ağacan <omer@well-typed.com>
  15. 20 Oct, 2019 1 commit
  16. 14 Jul, 2019 1 commit
    • John Ericson's avatar
      Expunge #ifdef and #ifndef from the codebase · d7c6c471
      John Ericson authored
      These are unexploded minds as far as the linter is concerned. I don't
      want to hit in my MRs by mistake!
      I did this with `sed`, and then rolled back some changes in the docs,
      config.guess, and the linter itself.
  17. 25 May, 2019 1 commit
  18. 20 Mar, 2019 1 commit
    • Ben Gamari's avatar
      rts/RtsSymbols: Drop __mingw_vsnwprintf · ae382245
      Ben Gamari authored
      As described in #16387, this is already defined by mingw and
      consequently defining it in the RTS as well leads to multiple definition
      errors from the RTS linker at runtime.
  19. 17 Mar, 2019 1 commit
    • Ben Gamari's avatar
      ghc-heap: Introduce closureSize · cb61371e
      Ben Gamari authored
      This function allows the user to compute the (non-transitive) size of a
      heap object in words. The "closure" in the name is admittedly confusing
      but we are stuck with this nomenclature at this point.
  20. 12 Jan, 2019 1 commit
  21. 01 Jan, 2019 1 commit
  22. 29 Dec, 2018 1 commit
    • Sergei Trofimovich's avatar
      rts: fix build failure on OpenBSD (_DYNAMIC symbol collision) · 1638350f
      Sergei Trofimovich authored
      Build failure on OpenBSD-6.4 the the following:
      rts/RtsSymbols.c:994:1: error:
           error: redefinition of '_DYNAMIC' as different kind of symbol
          | ^
      On OpenBSD `_DYNAMIC` was always defined in `<elf.h>` headers
      but used not to be included.
      The change explicitly includes `<elf.h>` as a source of symbol definition.
      Signed-off-by: default avatarSergei Trofimovich <slyfox@gentoo.org>
      Test Plan: build-tested on OpenBSD-6.4
      Reviewers: bgamari, erikd, simonmar
      Subscribers: rwbarton, carter
      GHC Trac Issues: #15945
      Differential Revision: https://phabricator.haskell.org/D5461
  23. 29 Aug, 2018 1 commit
    • David Feuer's avatar
      Finish stable split · f48e276a
      David Feuer authored
      Long ago, the stable name table and stable pointer tables were one.
      Now, they are separate, and have significantly different
      implementations. I believe the time has come to finish the split
      that began in #7674.
      * Divide `rts/Stable` into `rts/StableName` and `rts/StablePtr`.
      * Give each table its own mutex.
      * Add FFI functions `hs_lock_stable_ptr_table` and
      `hs_unlock_stable_ptr_table` and document them.
        These are intended to replace the previously undocumented
      `hs_lock_stable_tables` and `hs_lock_stable_tables`,
        which are now documented as deprecated synonyms.
      * Make `eqStableName#` use pointer equality instead of unnecessarily
      comparing stable name table indices.
      Reviewers: simonmar, bgamari, erikd
      Reviewed By: bgamari
      Subscribers: rwbarton, carter
      GHC Trac Issues: #15555
      Differential Revision: https://phabricator.haskell.org/D5084
  24. 21 Aug, 2018 1 commit
  25. 15 Jul, 2018 1 commit
  26. 05 Jun, 2018 1 commit
    • Ömer Sinan Ağacan's avatar
      Rename some mutable closure types for consistency · 4075656e
      Ömer Sinan Ağacan authored
      Naming is now consistent with other CLEAR/DIRTY objects (MVAR, MUT_VAR,
      (alternatively we could rename MVAR_DIRTY/MVAR_CLEAN etc. to MVAR0/MVAR)
      Removed a few comments in Scav.c about FROZEN0 being on the mut_list
      because it's now clear from the closure type.
      Reviewers: bgamari, simonmar, erikd
      Reviewed By: simonmar
      Subscribers: rwbarton, thomie, carter
      Differential Revision: https://phabricator.haskell.org/D4784
  27. 02 Jun, 2018 1 commit
  28. 16 May, 2018 1 commit
    • Simon Marlow's avatar
      An overhaul of the SRT representation · eb8e692c
      Simon Marlow authored
      - Previously we would hvae a single big table of pointers per module,
        with a set of bitmaps to reference entries within it. The new
        representation is identical to a static constructor, which is much
        simpler for the GC to traverse, and we get to remove the complicated
        bitmap-traversal code from the GC.
      - Rewrite all the code to generate SRTs in CmmBuildInfoTables, and
        document it much better (see Note [SRTs]). This has been something
        I've wanted to do since we moved to the new code generator, I
        finally had the opportunity to finish it while on a transatlantic
        flight recently :)
      There are a series of 4 diffs:
      1. D4632 (this one), which does the bulk of the changes
      2. D4633 which adds support for smaller `CmmLabelDiffOff` constants
      3. D4634 which takes advantage of D4632 and D4633 to save a word in
         info tables that have an SRT on x86_64. This is where most of the
         binary size improvement comes from.
      4. D4637 which makes a further optimisation to merge some SRTs with
         static FUN closures.  This adds some complexity and the benefits
         are fairly modest, so it's not clear yet whether we should do this.
      Results (after (3), on x86_64)
      - GHC itself (staticaly linked) is 5.2% smaller
      - -1.7% binary sizes in nofib, -2.9% module sizes. Full nofib results: P176
      - I measured the overhead of traversing all the static objects in a
        major GC in GHC itself by doing `replicateM_ 1000 performGC` as the
        first thing in `Main.main`.  The new version was 5-10% faster, but
        the results did vary quite a bit.
      - I'm not sure if there's a compile-time difference, the results are
        too unreliable.
      Test Plan: validate
      Reviewers: bgamari, michalt, niteria, simonpj, erikd, osa1
      Subscribers: thomie, carter
      Differential Revision: https://phabricator.haskell.org/D4632
  29. 31 Mar, 2018 1 commit
    • Tamar Christina's avatar
      Remove MAX_PATH restrictions from RTS, I/O manager and various utilities · 4de585a5
      Tamar Christina authored
      This shims out fopen and sopen so that they use modern APIs under the hood
      along with namespaced paths.
      This lifts the MAX_PATH restrictions from Haskell programs and makes the new
      limit ~32k.
      There are only some slight caveats that have been documented.
      Some utilities have not been upgraded such as lndir, since all these things are
      different cabal packages I have been forced to copy the source in different places
      which is less than ideal. But it's the only way to keep sdist working.
      Test Plan: ./validate
      Reviewers: hvr, bgamari, erikd, simonmar
      Reviewed By: bgamari
      Subscribers: rwbarton, thomie, carter
      GHC Trac Issues: #10822
      Differential Revision: https://phabricator.haskell.org/D4416