1. 21 Sep, 2012 1 commit
  2. 14 Sep, 2012 1 commit
  3. 07 Sep, 2012 1 commit
    • Simon Marlow's avatar
      Deprecate lnat, and use StgWord instead · 41737f12
      Simon Marlow authored
      lnat was originally "long unsigned int" but we were using it when we
      wanted a 64-bit type on a 64-bit machine.  This broke on Windows x64,
      where long == int == 32 bits.  Using types of unspecified size is bad,
      but what we really wanted was a type with N bits on an N-bit machine.
      StgWord is exactly that.
      
      lnat was mentioned in some APIs that clients might be using
      (e.g. StackOverflowHook()), so we leave it defined but with a comment
      to say that it's deprecated.
      41737f12
  4. 02 Jul, 2012 1 commit
  5. 26 Apr, 2012 1 commit
    • Ian Lynagh's avatar
      Fix warnings on Win64 · 1dbe6d59
      Ian Lynagh authored
      Mostly this meant getting pointer<->int conversions to use the right
      sizes. lnat is now size_t, rather than unsigned long, as that seems a
      better match for how it's used.
      1dbe6d59
  6. 04 Apr, 2012 1 commit
    • Duncan Coutts's avatar
      Add new eventlog events for various heap and GC statistics · 65aaa9b2
      Duncan Coutts authored
      They cover much the same info as is available via the GHC.Stats module
      or via the '+RTS -s' textual output, but via the eventlog and with a
      better sampling frequency.
      
      We have three new generic heap info events and two very GHC-specific
      ones. (The hope is the general ones are usable by other implementations
      that use the same eventlog system, or indeed not so sensitive to changes
      in GHC itself.)
      
      The general ones are:
      
       * total heap mem allocated since prog start, on a per-HEC basis
       * current size of the heap (MBlocks reserved from OS for the heap)
       * current size of live data in the heap
      
      Currently these are all emitted by GHC at GC time (live data only at
      major GC).
      
      The GHC specific ones are:
      
       * an event giving various static heap paramaters:
         * number of generations (usually 2)
         * max size if any
         * nursary size
         * MBlock and block sizes
       * a event emitted on each GC containing:
         * GC generation (usually just 0,1)
         * total bytes copied
         * bytes lost to heap slop and fragmentation
         * the number of threads in the parallel GC (1 for serial)
         * the maximum number of bytes copied by any par GC thread
         * the total number of bytes copied by all par GC threads
           (these last three can be used to calculate an estimate of the
            work balance in parallel GCs)
      65aaa9b2
  7. 27 Feb, 2012 1 commit
  8. 14 Dec, 2011 1 commit
  9. 13 Dec, 2011 1 commit
    • Simon Marlow's avatar
      New flag +RTS -qi<n>, avoid waking up idle Capabilities to do parallel GC · a02eb298
      Simon Marlow authored
      This is an experimental tweak to the parallel GC that avoids waking up
      a Capability to do parallel GC if we know that the capability has been
      idle for a (tunable) number of GC cycles.  The idea is that if you're
      only using a few Capabilities, there's no point waking up the ones
      that aren't busy.
      
      e.g. +RTS -qi3
      
      says "A Capability will participate in parallel GC if it was running
      at all since the last 3 GC cycles."
      
      Results are a bit hit and miss, and I don't completely understand why
      yet.  Hence, for now it is turned off by default, and also not
      documented except in the +RTS -? output.
      a02eb298
  10. 01 Dec, 2011 1 commit
  11. 29 Nov, 2011 1 commit
    • Simon Marlow's avatar
      Make profiling work with multiple capabilities (+RTS -N) · 50de6034
      Simon Marlow authored
      This means that both time and heap profiling work for parallel
      programs.  Main internal changes:
      
        - CCCS is no longer a global variable; it is now another
          pseudo-register in the StgRegTable struct.  Thus every
          Capability has its own CCCS.
      
        - There is a new built-in CCS called "IDLE", which records ticks for
          Capabilities in the idle state.  If you profile a single-threaded
          program with +RTS -N2, you'll see about 50% of time in "IDLE".
      
        - There is appropriate locking in rts/Profiling.c to protect the
          shared cost-centre-stack data structures.
      
      This patch does enough to get it working, I have cut one big corner:
      the cost-centre-stack data structure is still shared amongst all
      Capabilities, which means that multiple Capabilities will race when
      updating the "allocations" and "entries" fields of a CCS.  Not only
      does this give unpredictable results, but it runs very slowly due to
      cache line bouncing.
      
      It is strongly recommended that you use -fno-prof-count-entries to
      disable the "entries" count when profiling parallel programs. (I shall
      add a note to this effect to the docs).
      50de6034
  12. 25 Nov, 2011 1 commit
    • Simon Marlow's avatar
      Time handling overhaul · 6b109851
      Simon Marlow authored
      Terminology cleanup: the type "Ticks" has been renamed "Time", which
      is an StgWord64 in units of TIME_RESOLUTION (currently nanoseconds).
      The terminology "tick" is now used consistently to mean the interval
      between timer signals.
      
      The ticker now always ticks in realtime (actually CLOCK_MONOTONIC if
      we have it).  Before it used CPU time in the non-threaded RTS and
      realtime in the threaded RTS, but I've discovered that the CPU timer
      has terrible resolution (at least on Linux) and isn't much use for
      profiling.  So now we always use realtime.  This should also fix
      
      The default tick interval is now 10ms, except when profiling where we
      drop it to 1ms.  This gives more accurate profiles without affecting
      runtime too much (<1%).
      
      Lots of cleanups - the resolution of Time is now in one place
      only (Rts.h) rather than having calculations that depend on the
      resolution scattered all over the RTS.  I hope I found them all.
      6b109851
  13. 16 Nov, 2011 1 commit
    • Simon Marlow's avatar
      Generate the C main() function when linking a binary (fixes #5373) · 1df28a80
      Simon Marlow authored
      Rather than have main() be statically compiled as part of the RTS, we
      now generate it into the tiny C file that we compile when linking a
      binary.
      
      The main motivation is that we want to pass the settings for the
      -rtsotps and -with-rtsopts flags into the RTS, rather than relying on
      fragile linking semantics to override the defaults, which don't work
      with DLLs on Windows (#5373).  In order to do this, we need to extend
      the API for initialising the RTS, so now we have:
      
      void hs_init_ghc (int *argc, char **argv[],   // program arguments
                        RtsConfig rts_config);      // RTS configuration
      
      hs_init_ghc() can optionally be used instead of hs_init(), and allows
      passing in configuration options for the RTS.  RtsConfig is a struct,
      which currently has two fields:
      
      typedef struct {
          RtsOptsEnabledEnum rts_opts_enabled;
          const char *rts_opts;
      } RtsConfig;
      
      but might have more in the future.  There is a default value for the
      struct, defaultRtsConfig, the idea being that you start with this and
      override individual fields as necessary.
      
      In fact, main() was in a separate static library, libHSrtsmain.a.
      That's now gone.
      1df28a80
  14. 02 Nov, 2011 1 commit
    • Simon Marlow's avatar
      Overhaul of infrastructure for profiling, coverage (HPC) and breakpoints · 7bb0447d
      Simon Marlow authored
      User visible changes
      ====================
      
      Profilng
      --------
      
      Flags renamed (the old ones are still accepted for now):
      
        OLD            NEW
        ---------      ------------
        -auto-all      -fprof-auto
        -auto          -fprof-exported
        -caf-all       -fprof-cafs
      
      New flags:
      
        -fprof-auto              Annotates all bindings (not just top-level
                                 ones) with SCCs
      
        -fprof-top               Annotates just top-level bindings with SCCs
      
        -fprof-exported          Annotates just exported bindings with SCCs
      
        -fprof-no-count-entries  Do not maintain entry counts when profiling
                                 (can make profiled code go faster; useful with
                                 heap profiling where entry counts are not used)
      
      Cost-centre stacks have a new semantics, which should in most cases
      result in more useful and intuitive profiles.  If you find this not to
      be the case, please let me know.  This is the area where I have been
      experimenting most, and the current solution is probably not the
      final version, however it does address all the outstanding bugs and
      seems to be better than GHC 7.2.
      
      Stack traces
      ------------
      
      +RTS -xc now gives more information.  If the exception originates from
      a CAF (as is common, because GHC tends to lift exceptions out to the
      top-level), then the RTS walks up the stack and reports the stack in
      the enclosing update frame(s).
      
      Result: +RTS -xc is much more useful now - but you still have to
      compile for profiling to get it.  I've played around a little with
      adding 'head []' to GHC itself, and +RTS -xc does pinpoint the problem
      quite accurately.
      
      I plan to add more facilities for stack tracing (e.g. in GHCi) in the
      future.
      
      Coverage (HPC)
      --------------
      
       * derived instances are now coloured yellow if they weren't used
       * likewise record field names
       * entry counts are more accurate (hpc --fun-entry-count)
       * tab width is now correct (markup was previously off in source with
         tabs)
      
      Internal changes
      ================
      
      In Core, the Note constructor has been replaced by
      
              Tick (Tickish b) (Expr b)
      
      which is used to represent all the kinds of source annotation we
      support: profiling SCCs, HPC ticks, and GHCi breakpoints.
      
      Depending on the properties of the Tickish, different transformations
      apply to Tick.  See CoreUtils.mkTick for details.
      
      Tickets
      =======
      
      This commit closes the following tickets, test cases to follow:
      
        - Close #2552: not a bug, but the behaviour is now more intuitive
          (test is T2552)
      
        - Close #680 (test is T680)
      
        - Close #1531 (test is result001)
      
        - Close #949 (test is T949)
      
        - Close #2466: test case has bitrotted (doesn't compile against current
          version of vector-space package)
      7bb0447d
  15. 31 Oct, 2011 2 commits
  16. 27 Oct, 2011 5 commits
    • Duncan Coutts's avatar
      Allow the -t -T -s -S flags (without <file> arg!) in -rtsopts=some mode · 6dfd9016
      Duncan Coutts authored
      Without any <file> arg, these flags just dump info to stderr so
      are at most a mild information disclosure danger. We disallow
      a <file> arg in the default -rtsopts=some mode since that will
      overwrite the given file.
      6dfd9016
    • Duncan Coutts's avatar
      Change what +RTS options are available by default · 8c7ad0bd
      Duncan Coutts authored
      Ticket #3910 originally pointed out that the RTS options are a potential
      security problem. For example the -t -s or -S flags can be used to
      overwrite files. This would be bad in the context of CGI scripts or
      setuid binaries. So we introduced a system where +RTS processing is more
      or less disabled unless you pass the -rtsopts flag at link time.
      
      This scheme is safe enough but it also really annoies users. They have
      to use -rtsopts in many circumstances: with -threaded to use -N, with
      -eventlog to use -l, with -prof to use any of the profiling flags. Many
      users just set -rtsopts globally or in project .cabal files. Apart from
      annoying users it reduces security because it means that deployed
      binaries will have all RTS options enabled rather than just profiling
      ones.
      
      This patch relaxes the set of RTS options that are available in the
      default -rtsopts=some case. For "deployment" ways like vanilla and
      -threaded we remain quite conservative. Only --info -? --help are
      allowed for vanilla. For -threaded, -N and -N<x> are allowed with a
      check that x <= num cpus.
      
      For "developer" ways like -debug, -eventlog, -prof, we allow all the
      options that are special to that way. Some of these allow writing files,
      but the file written is not directly under the control of the attacker.
      For the setuid case (where the attacker would have control over binary
      name, current dir, local symlinks etc) we check if the process is
      running setuid/setgid and refuse all RTS option processing. Users would
      need to use -rtsopts=all in this case.
      
      We are making the assumption that developers will not deploy binaries
      built in the -debug, -eventlog, -prof ways. And even if they do, the
      damage should be limited to DOS, information disclosure and writing
      files like <progname>.eventlog, not arbitrary files.
      8c7ad0bd
    • Duncan Coutts's avatar
      Use signed comparison for +RTS -N x <= 0 test · 43a92710
      Duncan Coutts authored
      Otherwise we can use +RTS -N-1 and get 2^32 or 2^64 capabilities
      which doesn't work out so well...
      43a92710
    • Duncan Coutts's avatar
    • Duncan Coutts's avatar
      Add an RTS eventlog tracing class for user messages · aaaaf67b
      Duncan Coutts authored
      Enables people to turn them on/off. Defaults to on.
      aaaaf67b
  17. 31 Jul, 2011 1 commit
    • Edward Z. Yang's avatar
      Implement public interface for GC statistics. · 2088abaf
      Edward Z. Yang authored
      
      
      We add a new RTS flag -T for collecting statistics but not giving any
      new inputs.  There is one new struct in rts/storage/GC.h: GCStats.  We
      add two new global counters current_residency and current_slop, which
      are useful for in-program GC statistics.
      
      See GHC.Stats in base for a Haskell interface to this functionality.
      Signed-off-by: Edward Z. Yang's avatarEdward Z. Yang <ezyang@mit.edu>
      2088abaf
  18. 18 Jul, 2011 4 commits
  19. 05 Jun, 2011 1 commit
    • Ian Lynagh's avatar
      Fix Windows build failure · 183d6c8e
      Ian Lynagh authored
      We were calling freeArgv with arguments of the wrong type.
      But actually, we had our own copy of its loop anyway, so
      now we just use that instead.
      183d6c8e
  20. 25 May, 2011 1 commit
  21. 14 May, 2011 1 commit
  22. 12 Apr, 2011 1 commit
    • Simon Marlow's avatar
      Cleanup sweep and fix a bug in RTS flag processing. · 5463b55b
      Simon Marlow authored
      This code has accumulated a great deal of cruft over the years, this
      pass cleans up a lot of the surrounding cruft but leaves the actual
      argument processing alone - so there's still more that could be done.
      
      Bug fixed:
      
        - ghc_rts_opts should not be subject to the --rtsopts setting.  If
          the programmer explicitly declares options with ghc_rts_opts, they
          shouldn't also have to accept command-line RTS options to make them
          work.
      5463b55b
  23. 29 Mar, 2011 1 commit
  24. 01 Feb, 2011 1 commit
  25. 16 Dec, 2010 1 commit
  26. 15 Dec, 2010 1 commit
    • Simon Marlow's avatar
      Implement stack chunks and separate TSO/STACK objects · f30d5273
      Simon Marlow authored
      This patch makes two changes to the way stacks are managed:
      
      1. The stack is now stored in a separate object from the TSO.
      
      This means that it is easier to replace the stack object for a thread
      when the stack overflows or underflows; we don't have to leave behind
      the old TSO as an indirection any more.  Consequently, we can remove
      ThreadRelocated and deRefTSO(), which were a pain.
      
      This is obviously the right thing, but the last time I tried to do it
      it made performance worse.  This time I seem to have cracked it.
      
      2. Stacks are now represented as a chain of chunks, rather than
         a single monolithic object.
      
      The big advantage here is that individual chunks are marked clean or
      dirty according to whether they contain pointers to the young
      generation, and the GC can avoid traversing clean stack chunks during
      a young-generation collection.  This means that programs with deep
      stacks will see a big saving in GC overhead when using the default GC
      settings.
      
      A secondary advantage is that there is much less copying involved as
      the stack grows.  Programs that quickly grow a deep stack will see big
      improvements.
      
      In some ways the implementation is simpler, as nothing special needs
      to be done to reclaim stack as the stack shrinks (the GC just recovers
      the dead stack chunks).  On the other hand, we have to manage stack
      underflow between chunks, so there's a new stack frame
      (UNDERFLOW_FRAME), and we now have separate TSO and STACK objects.
      The total amount of code is probably about the same as before.
      
      There are new RTS flags:
      
         -ki<size> Sets the initial thread stack size (default 1k)  Egs: -ki4k -ki2m
         -kc<size> Sets the stack chunk size (default 32k)
         -kb<size> Sets the stack chunk buffer size (default 1k)
      
      -ki was previously called just -k, and the old name is still accepted
      for backwards compatibility.  These new options are documented.
      f30d5273
  27. 28 Oct, 2010 1 commit
  28. 05 Aug, 2010 1 commit
    • Ian Lynagh's avatar
      Make -rtsopts more flexible · 32073806
      Ian Lynagh authored
      The default is a new "some" state, which allows only known-safe flags
      that we want on by default. Currently this is only "--info".
      32073806
  29. 22 Jun, 2010 1 commit
    • dmp@rice.edu's avatar
      Add support for collecting PAPI native events · d4942f78
      dmp@rice.edu authored
      This patch extends the PAPI support in the RTS to allow collection of native
      events. PAPI can collect data for native events that are exposed by the
      hardware beyond the PAPI present events. The native events supported on your
      hardware can found by using the papi_native_avail tool.
      
      The RTS already allows users to specify PAPI preset events from the command
      line. This patch extends that support to allow users to specify native events.
      The changes needed are:
      
      1) New option (#) for the RTS PAPI flag for native events. For example, to
         collect the native event 0x40000000, use ./a.out +RTS -a#0x40000000 -sstderr
      
      2) Update the PAPI_FLAGS struct to store whether the user specified event is a
         papi preset or a native event
      
      3) Update init_countable_events function to add the native events after parsing
         the event code and decoding the name using PAPI_event_code_to_name
      d4942f78
  30. 26 Apr, 2010 1 commit
  31. 15 Mar, 2010 1 commit
  32. 13 Mar, 2010 1 commit
    • Ian Lynagh's avatar
      Add a link-time flag to en/disable the RTS options · 929d1669
      Ian Lynagh authored
      If RTS options are disabled then:
      * The ghc_rts_opts C code variable is processed as normal
      * The GHCRTS environment variable is ignored and, if it is defined, a
        warning is emitted
      * The +RTS flag gives an error and terminates the program
      929d1669