1. 11 Dec, 2016 1 commit
    • Moritz Angermann's avatar
      Make globals use sharedCAF · c3c70244
      Moritz Angermann authored
      Summary:
      The use of globals is quite painful when multiple rts are loaded, e.g.
      when plugins are loaded, which bring in a second rts. The sharedCAF
      appraoch was employed for the FastStringTable; I've taken the libery
      to extend this to the other globals I could find.
      
      This is a reboot of D2575, that should hopefully not exhibit the same
      windows build issues.
      
      Reviewers: Phyx, simonmar, goldfire, bgamari, austin, hvr, erikd
      
      Reviewed By: Phyx, simonmar, bgamari
      
      Subscribers: mpickering, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2773
      c3c70244
  2. 07 Dec, 2016 1 commit
    • Simon Marlow's avatar
      Overhaul of Compact Regions (#12455) · 7036fde9
      Simon Marlow authored
      Summary:
      This commit makes various improvements and addresses some issues with
      Compact Regions (aka Compact Normal Forms).
      
      This was the most important thing I wanted to fix.  Compaction
      previously prevented GC from running until it was complete, which
      would be a problem in a multicore setting.  Now, we compact using a
      hand-written Cmm routine that can be interrupted at any point.  When a
      GC is triggered during a sharing-enabled compaction, the GC has to
      traverse and update the hash table, so this hash table is now stored
      in the StgCompactNFData object.
      
      Previously, compaction consisted of a deepseq using the NFData class,
      followed by a traversal in C code to copy the data.  This is now done
      in a single pass with hand-written Cmm (see rts/Compact.cmm). We no
      longer use the NFData instances, instead the Cmm routine evaluates
      components directly as it compacts.
      
      The new compaction is about 50% faster than the old one with no
      sharing, and a little faster on average with sharing (the cost of the
      hash table dominates when we're doing sharing).
      
      Static objects that don't (transitively) refer to any CAFs don't need
      to be copied into the compact region.  In particular this means we
      often avoid copying Char values and small Int values, because these
      are static closures in the runtime.
      
      Each Compact# object can support a single compactAdd# operation at any
      given time, so the Data.Compact library now enforces mutual exclusion
      using an MVar stored in the Compact object.
      
      We now get exceptions rather than killing everything with a barf()
      when we encounter an object that cannot be compacted (a function, or a
      mutable object).  We now also detect pinned objects, which can't be
      compacted either.
      
      The Data.Compact API has been refactored and cleaned up.  A new
      compactSize operation returns the size (in bytes) of the compact
      object.
      
      Most of the documentation is in the Haddock docs for the compact
      library, which I've expanded and improved here.
      
      Various comments in the code have been improved, especially the main
      Note [Compact Normal Forms] in rts/sm/CNF.c.
      
      I've added a few tests, and expanded a few of the tests that were
      there.  We now also run the tests with GHCi, and in a new test way
      that enables sanity checking (+RTS -DS).
      
      There's a benchmark in libraries/compact/tests/compact_bench.hs for
      measuring compaction speed and comparing sharing vs. no sharing.
      
      The field totalDataW in StgCompactNFData was unnecessary.
      
      Test Plan:
      * new unit tests
      * validate
      * tested manually that we can compact Data.Aeson data
      
      Reviewers: gcampax, bgamari, ezyang, austin, niteria, hvr, erikd
      
      Subscribers: thomie, simonpj
      
      Differential Revision: https://phabricator.haskell.org/D2751
      
      GHC Trac Issues: #12455
      7036fde9
  3. 06 Dec, 2016 1 commit
    • Simon Marlow's avatar
      Overhaul GC stats · 24e6594c
      Simon Marlow authored
      Summary:
      Visible API changes:
      
      * The C struct `GCDetails` gives the stats about a single GC.  This is
        passed to the `gcDone()` callback if one is set via the
        RtsConfig. (previously we just passed a collection of values, so this
        is more extensible, at the expense of breaking the existing API)
      
      * `RTSStats` gives cumulative stats since the start of the program,
        and includes the `GCDetails` for the most recent GC.  This struct
        can be obtained via `getRTSStats()` (the old `getGCStats()` has been
        removed, and `getGCStatsEnabled()` has been renamed to
        `getRTSStatsEnabled()`)
      
      Improvements:
      
      * The per-GC stats and cumulative stats are now cleanly separated.
      
      * Inside the RTS we have a top-level `RTSStats` struct to keep all our
        stats in, previously this was just a collection of strangely-named
        variables.  This struct is mostly just copied in `getRTSStats()`, so
        the implementation of that function is a lot shorter.
      
      * Types are more consistent.  We use a uint64_t byte count for all
        memory values, and Time for all time values.
      
      * Names are more consistent.  We use a suffix `_bytes` for all byte
        counts and `_ns` for all time values.
      
      * We now collect information about the amount of memory in large
        objects and compact objects in `GCDetails`. (the latter was the reason
        I started doing this patch but it seems to have ballooned a bit!)
      
      * I fixed a bug in the calculation of the elapsed MUT time, and added
        an ASSERT to stop the calculations going wrong in the future.
      
      For now I kept the Haskell API in `GHC.Stats` the same, by
      impedence-matching with the new API.  We could either break that API
      and make it match the C API more closely, or we could add a new API
      and deprecate the old one.  Opinions welcome.
      
      This stuff is very easy to get wrong, and it's hard to test.  Reviews
      welcome!
      
      Test Plan:
      manual testing
      validate
      
      Reviewers: bgamari, niteria, austin, ezyang, hvr, erikd, rwbarton, Phyx
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2756
      24e6594c
  4. 02 Dec, 2016 1 commit
    • Simon Marlow's avatar
      fdReady: use poll() instead of select() · f46369b8
      Simon Marlow authored
      select() is limited to 1024 file descriptors.  This actually blew up
      in a very hard-to-debug way in our production system when using the
      hinotify package.
      
      Test Plan:
      libraries/tests pass, paricularly hGetBuf001 which exercises this
      code.
      
      Reviewers: niteria, erikd, austin, hvr, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2785
      
      GHC Trac Issues: #12912
      f46369b8
  5. 01 Dec, 2016 2 commits
    • Kai Ruemmler's avatar
      Fix naming of the native latin1 encodings · 747e77c9
      Kai Ruemmler authored
      textEncodingName is notjust a string, it must be a valid input for
      mkTextEncoding, as stated in libraries/base/GHC/IO/Encoding/Types.hs.
      
      Test Plan:
      A working latin1 locale is required on the system.  Reason: ghc's
      initial locale encoding defaults to ASCII, if either an unknown locale
      or unknown charset is used.  For the bug to show up, ghc must start up
      using the latin1 encoding.
      
      From main directory in ghc do:
      $ ./configure && make clean && make boot && make inplace/bin/ghc-stage2
      $ LC_CTYPE="de_DE.ISO-8859-1" ./inplace/bin/ghc-stage2
      
      Before the patch, the last line leads to the exception thrown:
      ghc-stage2: mkTextEncoding: does not exist (unknown
      encoding:ISO8859-1(checked)//TRANSLIT)
      
      After the patch, ghc-stage2 prints a short usage summary as expected.
      Moreover,
      $ make test TEST=encoding005
      continues to  pass after the patch.
      
      Reviewers: austin, hvr, rwbarton, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: mpickering, rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2667
      747e77c9
    • Gabor Greif's avatar
      Typos in comments · 0f37550c
      Gabor Greif authored
      0f37550c
  6. 30 Nov, 2016 1 commit
  7. 29 Nov, 2016 2 commits
  8. 23 Nov, 2016 1 commit
    • Alexander Vershilov's avatar
      Allow to unregister threadWaitReadSTM action. · f4302534
      Alexander Vershilov authored
      Allow to unregister threadWaitReadSTM/threadWaitWriteSTM on
      a non-threaded runtime. Previosly noop action was returned,
      as a result it was not possible to unregister action, unless
      data arrives to Fd or it's closed.
      
      Fixes #12852.
      
      Reviewers: simonmar, hvr, austin, bgamari, trofi
      
      Reviewed By: bgamari, trofi
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2729
      
      GHC Trac Issues: #12852
      f4302534
  9. 18 Nov, 2016 1 commit
  10. 17 Nov, 2016 2 commits
  11. 10 Nov, 2016 1 commit
    • David Feuer's avatar
      Read parentheses better · bef7e784
      David Feuer authored
      Instead of pulling a token and looking for `'('` or `')'`,
      just look for the character itself. This prevents us from
      lexing every single item twice, once to see if it's a
      left parenthesis and once to actually parse it.
      
      Partially fixes #12665
      
      Make parens faster more aggressively
      
      * Strip spaces before parsing, so we never have to strip
      the same spaces twice.
      
      * String parsers together manually, to try to avoid unnecessary closure
      creation.
      
      Test Plan: Validate
      
      Reviewers: austin, hvr, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2630
      
      GHC Trac Issues: #12665
      bef7e784
  12. 31 Oct, 2016 1 commit
  13. 16 Oct, 2016 1 commit
  14. 15 Oct, 2016 1 commit
  15. 14 Oct, 2016 2 commits
    • Ryan Scott's avatar
      Add missing Semigroup instances for Monoidal datatypes in base · 8c6a3d68
      Ryan Scott authored
      Summary:
      There are currently three datatypes that are exposed in `base` that have
      `Monoid` instances, but no `Semigroup` instances:
      
      * `IO`
      * `Event` (from `GHC.Event`)
      * `Lifetime` (from `GHC.Event`)
      
      (There is also `EventLifetime` in `GHC.Event.Internal`, but it is not exported
      directly, so I didn't bother with it.)
      
      Adding the `Semigroup` instances for these types directly in the modules in
      which they're defined resulted in some horrific import cycles, so I opted to
      take the easy approach of defining all of these instances in `Data.Semigroup`.
      (When `Semigroup` becomes a superclass of `Monoid`, these instances will have
      to be moved somehow.)
      
      Fixes #12464.
      
      Test Plan: It compiles
      
      Reviewers: hvr, ekmett, austin, bgamari
      
      Reviewed By: ekmett
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2588
      
      GHC Trac Issues: #12464
      8c6a3d68
    • Ben Gamari's avatar
      Clean up handling of known-key Names in interface files · 34d933d6
      Ben Gamari authored
      Previously BinIface had some dedicated logic for handling tuple names in
      the symbol table. As it turns out, this logic was essentially dead code
      as it was superceded by the special handling of known-key things. Here
      we cull the tuple code-path and use the known-key codepath for all
      tuple-ish things.
      
      This had a surprising number of knock-on effects,
      
       * constraint tuple datacons had to be made known-key (previously they
         were not)
      
       * IfaceTopBndr was changed from being a synonym of OccName to a
         synonym of Name (since we now need to be able to deserialize Names
         directly from interface files)
      
       * the change to IfaceTopBndr complicated fingerprinting, since we need
         to ensure that we don't go looking for the fingerprint of the thing
         we are currently fingerprinting in the fingerprint environment (see
         notes in MkIface). Handling this required distinguishing between
         binding and non-binding Name occurrences in the Binary serializers.
      
       * the original name cache logic which previously lived in IfaceEnv has
         been moved to a new NameCache module
      
       * I ripped tuples and sums out of knownKeyNames since they introduce a
         very large number of entries. During interface file deserialization
         we use static functions (defined in the new KnownUniques module) to
         map from a Unique to a known-key Name (the Unique better correspond
         to a known-key name!) When we need to do an original name cache
         lookup we rely on the parser implemented in isBuiltInOcc_maybe.
      
       * HscMain.allKnownKeyNames was folded into PrelInfo.knownKeyNames.
      
       * Lots of comments were sprinkled about describing the new scheme.
      
      Updates haddock submodule.
      
      Test Plan: Validate
      
      Reviewers: niteria, simonpj, austin, hvr
      
      Reviewed By: simonpj
      
      Subscribers: simonmar, niteria, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2467
      
      GHC Trac Issues: #12532, #12415
      34d933d6
  16. 13 Oct, 2016 1 commit
  17. 09 Oct, 2016 1 commit
  18. 07 Oct, 2016 1 commit
    • niteria's avatar
      Fix memory leak from #12664 · e41b9c61
      niteria authored
      This fixes the leak with `setProgArgv`. The problem was
      that `setProgArgv` would not free the objects pointed
      to by `prog_argc`, `prog_argv` when the globals were
      changed resulting in a leak.
      
      The only strictly necessary change is in `rts/RtsFlags.c`, but
      the code in `System.Environment` was a bit confusing and not
      exception safe, so I refactored it.
      
      Test Plan: ./validate
      
      Reviewers: simonmar, ezyang, austin, hvr, bgamari, erikd
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2576
      
      GHC Trac Issues: #12664
      e41b9c61
  19. 02 Oct, 2016 1 commit
  20. 24 Sep, 2016 1 commit
    • Joachim Breitner's avatar
      Replace INLINEABLE by INLINABLE (#12613) · 68f72f10
      Joachim Breitner authored
      as the latter is the official, correct spelling, and the former just a
      misspelling accepted by GHC.
      
      Also document in the user’s guide that the alternative spelling is
      accepted
      
      This commit was brough to you by HIW 2016.
      68f72f10
  21. 23 Sep, 2016 1 commit
  22. 12 Sep, 2016 1 commit
    • Simon Marlow's avatar
      Add hs_try_putmvar() · 454033b5
      Simon Marlow authored
      Summary:
      This is a fast, non-blocking, asynchronous, interface to tryPutMVar that
      can be called from C/C++.
      
      It's useful for callback-based C/C++ APIs: the idea is that the callback
      invokes hs_try_putmvar(), and the Haskell code waits for the callback to
      run by blocking in takeMVar.
      
      The callback doesn't block - this is often a requirement of
      callback-based APIs.  The callback wakes up the Haskell thread with
      minimal overhead and no unnecessary context-switches.
      
      There are a couple of benchmarks in
      testsuite/tests/concurrent/should_run.  Some example results comparing
      hs_try_putmvar() with using a standard foreign export:
      
          ./hs_try_putmvar003 1 64 16 100 +RTS -s -N4     0.49s
          ./hs_try_putmvar003 2 64 16 100 +RTS -s -N4     2.30s
      
      hs_try_putmvar() is 4x faster for this workload (see the source for
      hs_try_putmvar003.hs for details of the workload).
      
      An alternative solution is to use the IO Manager for this.  We've tried
      it, but there are problems with that approach:
      * Need to create a new file descriptor for each callback
      * The IO Manger thread(s) become a bottleneck
      * More potential for things to go wrong, e.g. throwing an exception in
        an IO Manager callback kills the IO Manager thread.
      
      Test Plan: validate; new unit tests
      
      Reviewers: niteria, erikd, ezyang, bgamari, austin, hvr
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2501
      454033b5
  23. 10 Sep, 2016 1 commit
    • Tamar Christina's avatar
      Add platform warning to Foreign.C.Types · 710f21cc
      Tamar Christina authored
      Summary:
      The generated documentation for thhe Foreign.C.Types
      module is generated based on the platform which ran Haddock.
      
      This is generating incorrect types for e.g. Windows.
      
      Add a disclaimer to the top of the page to ask people to
      keep this in mind.
      
      Test Plan: make documentation and inspect Haddock
      
      Reviewers: erikd, austin, hvr, bgamari
      
      Reviewed By: erikd
      
      Subscribers: RyanGlScott, #ghc_windows_task_force, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2523
      
      GHC Trac Issues: #12586
      710f21cc
  24. 01 Sep, 2016 1 commit
    • Tamar Christina's avatar
      Added support for deprecated POSIX functions on Windows. · e5ecb201
      Tamar Christina authored
      Summary:
      With the introduction of 8.0.1 We've stopped supporting in GHCi
      the use of POSIX functions under their deprecated names on Windows.
      
      This to be compatible with object and libraries from the most
      popular compilers on the platform (Microsoft and Intel compilers).
      
      However this brings a confusing disparity between the compiled and
      interpreted behavior since MingW-W64 does support the deprecated names.
      
      Also It seems clear that package writers won't update their packages to
      properly support Windows. As such I have added redirects in the RTS
      for the deprecated functions as listed on
      
      https://msdn.microsoft.com/en-us/library/ms235384.aspx.
      
      This won't export the functions (as in, they won't be in the symbol table
      of compiled code for the RTS.) but we inject them into the symbol table
      of the dynamic linker at startup.
      
      Test Plan:
      ./validate
      and
      
      make test TEST="ffi017 ffi021"
      
      Reviewers: thomie, simonmar, RyanGlScott, bgamari, austin, hvr, erikd
      
      Reviewed By: simonmar, bgamari
      
      Subscribers: RyanGlScott, #ghc_windows_task_force
      
      Differential Revision: https://phabricator.haskell.org/D2500
      
      GHC Trac Issues: #12209, #12497, #12496
      e5ecb201
  25. 31 Aug, 2016 1 commit
    • Ryan Scott's avatar
      Add Read1/Read2 methods defined in terms of ReadPrec · 9cfef167
      Ryan Scott authored
      This adds new methods `liftReadList(2)` and `liftReadListPrec(2)` to the
      `Read1`/`Read2` classes which are defined in terms of `ReadPrec` instead
      of `ReadS`. This also adds related combinators and changes existing
      `Read1` and `Read2` instances to be defined in terms of the new methods.
      
      Reviewers: hvr, austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2379
      
      GHC Trac Issues: #12358
      9cfef167
  26. 18 Aug, 2016 1 commit
  27. 16 Aug, 2016 1 commit
  28. 08 Aug, 2016 1 commit
  29. 06 Aug, 2016 1 commit
  30. 04 Aug, 2016 1 commit
  31. 27 Jul, 2016 1 commit
  32. 20 Jul, 2016 2 commits
  33. 18 Jul, 2016 1 commit
  34. 16 Jul, 2016 1 commit
  35. 14 Jul, 2016 1 commit