1. 03 Aug, 2019 1 commit
    • Ben Gamari's avatar
      rts: Always truncate output files · 4664bafc
      Ben Gamari authored
      Previously there were numerous places in the RTS where we would fopen
      with the "w" flag string. This is wrong as it will not truncate the
      file. Consequently if we write less data than the previous length of the
      file we will leave garbage at its end.
      
      Fixes #16993.
      4664bafc
  2. 16 Jul, 2019 1 commit
    • Daniel Gröber (dxld)'s avatar
      rts: Divorce init of Heap profiler from CCS profiler · 373c9cb3
      Daniel Gröber (dxld) authored
      Currently initProfiling gets defined by Profiling.c only if PROFILING is
      defined. Otherwise the ProfHeap.c defines it.
      
      This is just needlessly complicated so in this commit I make Profiling and
      ProfHeap into properly seperate modules and call their respective init
      functions from RtsStartup.c.
      373c9cb3
  3. 05 Jul, 2019 1 commit
    • Daniel Gröber (dxld)'s avatar
      rts: Fix -hT option with profiling rts · ed662901
      Daniel Gröber (dxld) authored
      In dumpCensus we switch/case on doHeapProfile twice. The second switch
      tries to barf on unknown doHeapProfile modes but HEAP_BY_CLOSURE_TYPE is
      checked by the first switch and not included in the second.
      
      So when trying to pass -hT to the profiling rts it barfs.
      
      This commit simply merges the two switches into one which fixes this
      problem.
      ed662901
  4. 27 Jun, 2019 2 commits
  5. 07 Jun, 2019 1 commit
  6. 15 Mar, 2019 1 commit
  7. 25 Dec, 2018 1 commit
    • Ben Gamari's avatar
      rts: Turn ASSERT in LDV_recordDead into a normal if · 9b65ae69
      Ben Gamari authored
      As reported in #15382 the `ASSERT(ctr != NULL)` is currently getting routinely
      hit during testsuite runs. While this is certainly a bug I would far prefer
      getting a proper error message than a segmentation fault. Consequently I'm
      turning the `ASSERT` into a proper `if` so we get a proper error in non-debug
      builds.
      9b65ae69
  8. 11 Dec, 2018 1 commit
    • Zejun Wu's avatar
      Fix uninformative hp2ps error when the cmdline contains double quotes · 0136906c
      Zejun Wu authored
      Reapply D5346 with fix incompatible shell quoting in tests. It seems
      like `$'string'` is not recognized under all test environments, so let's
      avoid it in tests.
      
      Test Plan:
      ```
      hp2ps: "T15904".hp, line 2: integer must follow identifier
      ```
      
      use new ghc and hp2ps to profile a simple program.
      
      Reviewers: simonmar, bgamari, erikd, tdammers
      
      Reviewed By: bgamari
      
      Subscribers: tdammers, carter, rwbarton
      
      GHC Trac Issues: #15904
      
      Differential Revision: https://phabricator.haskell.org/D5388
      0136906c
  9. 24 Nov, 2018 1 commit
  10. 22 Nov, 2018 1 commit
    • Zejun Wu's avatar
      Fix uninformative hp2ps error when the cmdline contains double quotes · 390df8b5
      Zejun Wu authored
      The format of hp file didn't allow double quotes inside strings, and
      under prof build, we include args in JOB, which may have double quotes.
      When this happens, the error message is confusing to the user. This can
      also happen under normal build if the executable name contains double
      quite, which is unlikely though.
      
      We fix this issue by introducing escaping for double quotes inside a
      string by repeating it twice.
      
      We also fix a buffer overflow bug when the length of the string happen
      to be multiple of 5000.
      
      Test Plan:
      new tests, which used to fail with error message:
      
      ```
      hp2ps: "T15904".hp, line 2: integer must follow identifier
      ```
      
      use new ghc and hp2ps to profile a simple program.
      
      Reviewers: simonmar, bgamari, erikd
      
      Reviewed By: simonmar
      
      Subscribers: rwbarton, carter
      
      GHC Trac Issues: #15904
      
      Differential Revision: https://phabricator.haskell.org/D5346
      390df8b5
  11. 05 Jun, 2018 1 commit
    • Ömer Sinan Ağacan's avatar
      Rename some mutable closure types for consistency · 4075656e
      Ömer Sinan Ağacan authored
      SMALL_MUT_ARR_PTRS_FROZEN0 -> SMALL_MUT_ARR_PTRS_FROZEN_DIRTY
      SMALL_MUT_ARR_PTRS_FROZEN  -> SMALL_MUT_ARR_PTRS_FROZEN_CLEAN
      MUT_ARR_PTRS_FROZEN0       -> MUT_ARR_PTRS_FROZEN_DIRTY
      MUT_ARR_PTRS_FROZEN        -> MUT_ARR_PTRS_FROZEN_CLEAN
      
      Naming is now consistent with other CLEAR/DIRTY objects (MVAR, MUT_VAR,
      MUT_ARR_PTRS).
      
      (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
      4075656e
  12. 01 May, 2018 1 commit
    • Ben Gamari's avatar
      rts: Allow profiling by closure type in prof way · b7b6617a
      Ben Gamari authored
      Previously we inexplicably disabled support for `-hT` profiling in the profiled
      way. Admittedly, there are relatively few cases where one would prefer -hT to
      `-hd`, but the option should nevertheless be available for the sake of
      consistency.
      
      Note that this does mean that there is a bit of an inconsistency in the behavior
      of `-h`: in the profiled way `-h` behaves like `-hc` whereas in the non-profiled
      way it defaults to `-hT`.
      b7b6617a
  13. 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
      Summary:
      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
      4de585a5
  14. 26 Jul, 2017 1 commit
  15. 29 Apr, 2017 1 commit
  16. 14 Feb, 2017 1 commit
  17. 29 Nov, 2016 1 commit
  18. 14 Nov, 2016 1 commit
    • Simon Marlow's avatar
      Remove CONSTR_STATIC · 55d535da
      Simon Marlow authored
      Summary:
      We currently have two info tables for a constructor
      
      * XXX_con_info: the info table for a heap-resident instance of the
        constructor, It has type CONSTR, or one of the specialised types like
        CONSTR_1_0
      
      * XXX_static_info: the info table for a static instance of this
        constructor, which has type CONSTR_STATIC or CONSTR_STATIC_NOCAF.
      
      I'm getting rid of the latter, and using the `con_info` info table for
      both static and dynamic constructors.  For rationale and more details
      see Note [static constructors] in SMRep.hs.
      
      I also removed these macros: `isSTATIC()`, `ip_STATIC()`,
      `closure_STATIC()`, since they relied on the CONSTR/CONSTR_STATIC
      distinction, and anyway HEAP_ALLOCED() does the same job.
      
      Test Plan: validate
      
      Reviewers: bgamari, simonpj, austin, gcampax, hvr, niteria, erikd
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2690
      
      GHC Trac Issues: #12455
      55d535da
  19. 12 Sep, 2016 1 commit
  20. 20 Jul, 2016 1 commit
    • gcampax's avatar
      Compact Regions · cf989ffe
      gcampax authored
      This brings in initial support for compact regions, as described in the
      ICFP 2015 paper "Efficient Communication and Collection with Compact
      Normal Forms" (Edward Z. Yang et.al.) and implemented by Giovanni
      Campagna.
      
      Some things may change before the 8.2 release, but I (Simon M.) wanted
      to get the main patch committed so that we can iterate.
      
      What documentation there is is in the Data.Compact module in the new
      compact package.  We'll need to extend and polish the documentation
      before the release.
      
      Test Plan:
      validate
      (new test cases included)
      
      Reviewers: ezyang, simonmar, hvr, bgamari, austin
      
      Subscribers: vikraman, Yuras, RyanGlScott, qnikst, mboes, facundominguez, rrnewton, thomie, erikd
      
      Differential Revision: https://phabricator.haskell.org/D1264
      
      GHC Trac Issues: #11493
      cf989ffe
  21. 16 Jul, 2016 1 commit
  22. 10 Jun, 2016 1 commit
    • Simon Marlow's avatar
      NUMA support · 9e5ea67e
      Simon Marlow authored
      Summary:
      The aim here is to reduce the number of remote memory accesses on
      systems with a NUMA memory architecture, typically multi-socket servers.
      
      Linux provides a NUMA API for doing two things:
      * Allocating memory local to a particular node
      * Binding a thread to a particular node
      
      When given the +RTS --numa flag, the runtime will
      * Determine the number of NUMA nodes (N) by querying the OS
      * Assign capabilities to nodes, so cap C is on node C%N
      * Bind worker threads on a capability to the correct node
      * Keep a separate free lists in the block layer for each node
      * Allocate the nursery for a capability from node-local memory
      * Allocate blocks in the GC from node-local memory
      
      For example, using nofib/parallel/queens on a 24-core 2-socket machine:
      
      ```
      $ ./Main 15 +RTS -N24 -s -A64m
        Total   time  173.960s  (  7.467s elapsed)
      
      $ ./Main 15 +RTS -N24 -s -A64m --numa
        Total   time  150.836s  (  6.423s elapsed)
      ```
      
      The biggest win here is expected to be allocating from node-local
      memory, so that means programs using a large -A value (as here).
      
      According to perf, on this program the number of remote memory accesses
      were reduced by more than 50% by using `--numa`.
      
      Test Plan:
      * validate
      * There's a new flag --debug-numa=<n> that pretends to do NUMA without
        actually making the OS calls, which is useful for testing the code
        on non-NUMA systems.
      * TODO: I need to add some unit tests
      
      Reviewers: erikd, austin, rwbarton, ezyang, bgamari, hvr, niteria
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2199
      9e5ea67e
  23. 17 May, 2016 1 commit
    • Erik de Castro Lopo's avatar
      rts: More const correct-ness fixes · 33c029dd
      Erik de Castro Lopo authored
      In addition to more const-correctness fixes this patch fixes an
      infelicity of the previous const-correctness patch (995cf0f3) which
      left `UNTAG_CLOSURE` taking a `const StgClosure` pointer parameter
      but returning a non-const pointer. Here we restore the original type
      signature of `UNTAG_CLOSURE` and add a new function
      `UNTAG_CONST_CLOSURE` which takes and returns a const `StgClosure`
      pointer and uses that wherever possible.
      
      Test Plan: Validate on Linux, OS X and Windows
      
      Reviewers: Phyx, hsyl20, bgamari, austin, simonmar, trofi
      
      Reviewed By: simonmar, trofi
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2231
      33c029dd
  24. 12 May, 2016 1 commit
  25. 10 May, 2016 1 commit
    • wereHamster's avatar
      Use stdint types for Stg{Word,Int}{8,16,32,64} · 260a5648
      wereHamster authored
      We can't define Stg{Int,Word} in terms of {,u}intptr_t because STG
      depends on them being the exact same size as void*, and {,u}intptr_t
      does not make that guarantee. Furthermore, we also need to define
      StgHalf{Int,Word}, so the preprocessor if needs to stay. But we can at
      least keep it in a single place instead of repeating it in various
      files.
      
      Also define STG_{INT,WORD}{8,16,32,64}_{MIN,MAX} and use it in HsFFI.h,
      further reducing the need for CPP in other files.
      
      Reviewers: austin, bgamari, simonmar, hvr, erikd
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2182
      260a5648
  26. 08 May, 2016 1 commit
  27. 04 May, 2016 1 commit
  28. 20 Mar, 2016 1 commit
  29. 29 Jan, 2016 1 commit
  30. 26 Jan, 2016 1 commit
    • thomie's avatar
      Fix segmentation fault when .prof file not writeable · 6d2bdfd8
      thomie authored
      There are two ways to do retainer profiling. Quoting from the user's guide:
        1. `+RTS -hr` "Breaks down the graph by retainer set"
        2. `+RTS -hr<cc> -h<x>`, where `-h<x>` is one of normal heap profiling
           break-down options (e.g. `-hc`), and `-hr<cc> means "Restrict the
           profile to closures with retainer sets containing cost-centre
           stacks with one of the specified cost centres at the top."
      
      Retainer profiling writes to a .hp file, like the other heap profiling
      options, but also to a .prof file. Therefore, when the .prof file is not
      writeable for whatever reason, retainer profiling should be turned off
      completely.
      
      This worked ok when running the program with `+RTS -hr` (option 1), but a
      segfault would occur when using `+RTS -hr<cc> -h<x>`, with `x!=r` (option 2).
      
      This commit fixes that.
      
      Reviewed by: bgamari
      
      Differential Revision: https://phabricator.haskell.org/D1849
      
      GHC Trac Issues: #11489
      6d2bdfd8
  31. 23 Jan, 2016 1 commit
    • Joachim Breitner's avatar
      Remove unused IND_PERM · f42db157
      Joachim Breitner authored
      it seems that this closure type has not been in use since 5d52d9, so all
      this is dead and untested code. This removes it. Some of the code might
      be useful for a counting indirection as described in #10613, so when
      implementing that, have a look at what this commit removes.
      
      Test Plan: validate on harbormaster
      
      Reviewers: austin, bgamari, simonmar
      
      Reviewed By: simonmar
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1821
      f42db157
  32. 08 Jan, 2016 1 commit
  33. 21 Nov, 2015 1 commit
  34. 07 Nov, 2015 1 commit
    • Simon Marlow's avatar
      Make GHCi & TH work when the compiler is built with -prof · ce1f1607
      Simon Marlow authored
      Summary:
      Amazingly, there were zero changes to the byte code generator and very
      few changes to the interpreter - mainly because we've used good
      abstractions that hide the differences between profiling and
      non-profiling.  So that bit was pleasantly straightforward, but there
      were a pile of other wibbles to get the whole test suite through.
      
      Note that a compiler built with -prof is now like one built with
      -dynamic, in that to use TH you have to build the code the same way.
      For dynamic, we automatically enable -dynamic-too when TH is required,
      but we don't have anything equivalent for profiling, so you have to
      explicitly use -prof when building code that uses TH with a profiled
      compiler.  For this reason Cabal won't work with TH.  We don't expect
      to ship a profiled compiler, so I think that's OK.
      
      Test Plan: validate with GhcProfiled=YES in validate.mk
      
      Reviewers: goldfire, bgamari, rwbarton, austin, hvr, erikd, ezyang
      
      Reviewed By: ezyang
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1407
      
      GHC Trac Issues: #4837, #545
      ce1f1607
  35. 11 Sep, 2015 1 commit
  36. 06 May, 2015 1 commit
    • Javran Cheng's avatar
      rts: add "-no-rtsopts-suggestions" option · 477f514f
      Javran Cheng authored
      Depends on D767
      
      Setting this flag prevents RTS from giving RTS suggestions like "Use
      `+RTS -Ksize -RTS' to increase it."
      
      According to the comment @rwbarton made in #9579, sometimes "+RTS"
      suggestions don't make sense (e.g. when the program is precompiled and
      installed through package managers), we can encourage people to
      distribute binaries with either "-no-rtsopts-suggestions" or "-rtsopts".
      
      Reviewed By: erikd, austin
      
      Differential Revision: https://phabricator.haskell.org/D809
      
      GHC Trac Issues: #9579
      477f514f
  37. 17 Apr, 2015 1 commit
    • Javran Cheng's avatar
      Better hints when RTS options not available (Trac #9579) · 51af102e
      Javran Cheng authored
      This patch provides user with a better hint when most RTS options
      are not available (not compiled with `-rtsopts`).
      
      A new field "rtsOptsEnabled" is added into RtsFlags.MiscFlags to
      tell the availablity of RTS options.
      
      Some concerns:
      * Unlike other flag fields in "libraries/base/GHC/RTS/Flags.hsc",
        "RtsOptsEnabled" is defined in "includes/RtsAPI.h" and lacks
        constant macros. Therefore In "GHC.RTS", "RtsOptsEnabled" simply
        derives Enum instance and reads as of type "CInt".
      
      * There are other ways to change RTS options (e.g. `-with-rtsopts`),
        but it might be too verbose to mention.
      
      Test Plan: validate
      
      Reviewers: austin, hvr, thomie, simonmar
      
      Reviewed By: thomie
      
      Subscribers: thomie, rwbarton
      
      Differential Revision: https://phabricator.haskell.org/D767
      
      GHC Trac Issues: #9579
      51af102e
  38. 02 Mar, 2015 1 commit
  39. 21 Oct, 2014 1 commit