Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Commits on Jul 23, 2011
  1. @igfoo

    Fix heap profiling times

    igfoo authored
    Now that the heap census runs in the middle of garbage collections,
    the "CPU time" it was calculating included any CPU time used so far
    in the current GC. This could cause CPU time to appear to go down,
    which means hp2ps complained about "samples out of sequence".
    I'm not sure if this is the nicest way to solve this (maybe resurrecting
    mut_user_time_during_GC would be better?) but it gets things working again.
Commits on Jul 1, 2011
  1. @simonmar

    Better heap profiling for pinned objects (e.g. ByteStrings).

    simonmar authored
    Previously we were completely ignoring these, due to the difficulties
    of traversing the pinned blocks (the objects are not necessarily
    end-to-end, we can't tell how large the gaps are).  Now just count the
    whole block as a big ARR_WORDS, so at least we're accounting for the
    memory and it has the right type.
Commits on Jun 25, 2011
  1. @igfoo

    Fix gcc 4.6 warnings; fixes #5176

    igfoo authored
    Based on a patch from David Terei.
    Some parts are a little ugly (e.g. defining things that only ASSERTs
    use only when DEBUG is defined), so we might want to tweak things a
    I've also turned off -Werror for didn't-inline warnings, as we now
    get a few such warnings.
Commits on May 9, 2011
  1. @simonmar

    heapCensus: we need to traverse the heap fragments stored in the

    simonmar authored
    gen_workspace structures.  Fixes heapprof001(prof_hc_hb).
Commits on May 7, 2011
  1. @igfoo
Commits on Apr 12, 2011
  1. @simonmar

    Change the way module initialisation is done (#3252, #4417)

    simonmar authored
    Previously the code generator generated small code fragments labelled
    with __stginit_M for each module M, and these performed whatever
    initialisation was necessary for that module and recursively invoked
    the initialisation functions for imported modules.  This appraoch had
     - FFI users had to call hs_add_root() to ensure the correct
       initialisation routines were called.  This is a non-standard,
       and ugly, API.
     - unless we were using -split-objs, the __stginit dependencies would
       entail linking the whole transitive closure of modules imported,
       whether they were actually used or not.  In an extreme case (#4387,
       #4417), a module from GHC might be imported for use in Template
       Haskell or an annotation, and that would force the whole of GHC to
       be needlessly linked into the final executable.
    So now instead we do our initialisation with C functions marked with
    __attribute__((constructor)), which are automatically invoked at
    program startup time (or DSO load-time).  The C initialisers are
    emitted into the stub.c file.  This means that every time we compile
    with -prof or -hpc, we now get a stub file, but thanks to #3687 that
    is now invisible to the user.
    There are some refactorings in the RTS (particularly for HPC) to
    handle the fact that initialisers now get run earlier than they did
    The __stginit symbols are still generated, and the hs_add_root()
    function still exists (but does nothing), for backwards compatibility.
Commits on Dec 15, 2010
  1. @simonmar

    Implement stack chunks and separate TSO/STACK objects

    simonmar 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
    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
    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.
Commits on Apr 1, 2010
  1. @simonmar

    Remove the IND_OLDGEN and IND_OLDGEN_PERM closure types

    simonmar authored
    These are no longer used: once upon a time they used to have different
    layout from IND and IND_PERM respectively, but that is no longer the
    case since we changed the remembered set to be an array of addresses
    instead of a linked list of closures.
Commits on Mar 29, 2010
  1. @simonmar

    New implementation of BLACKHOLEs

    simonmar authored
    This replaces the global blackhole_queue with a clever scheme that
    enables us to queue up blocked threads on the closure that they are
    blocked on, while still avoiding atomic instructions in the common
     - gets rid of a locked global data structure and some tricky GC code
       (replacing it with some per-thread data structures and different
       tricky GC code :)
     - wakeups are more prompt: parallel/concurrent performance should
       benefit.  I haven't seen anything dramatic in the parallel
       benchmarks so far, but a couple of threading benchmarks do improve
       a bit.
     - waking up a thread blocked on a blackhole is now O(1) (e.g. if
       it is the target of throwTo).
     - less sharing and better separation of Capabilities: communication
       is done with messages, the data structures are strictly owned by a
       Capability and cannot be modified except by sending messages.
     - this change will utlimately enable us to do more intelligent
       scheduling when threads block on each other.  This is what started
       off the whole thing, but it isn't done yet (#3838).
    I'll be documenting all this on the wiki in due course.
Commits on Mar 11, 2010
  1. @simonmar

    Use message-passing to implement throwTo in the RTS

    simonmar authored
    This replaces some complicated locking schemes with message-passing
    in the implementation of throwTo. The benefits are
     - previously it was impossible to guarantee that a throwTo from
       a thread running on one CPU to a thread running on another CPU
       would be noticed, and we had to rely on the GC to pick up these
       forgotten exceptions. This no longer happens.
     - the locking regime is simpler (though the code is about the same
     - threads can be unblocked from a blocked_exceptions queue without
       having to traverse the whole queue now.  It's a rare case, but
       replaces an O(n) operation with an O(1).
     - generally we move in the direction of sharing less between
       Capabilities (aka HECs), which will become important with other
       changes we have planned.
    Also in this patch I replaced several STM-specific closure types with
    a generic MUT_PRIM closure type, which allowed a lot of code in the GC
    and other places to go away, hence the line-count reduction.  The
    message-passing changes resulted in about a net zero line-count
Commits on Dec 3, 2009
  1. @simonmar

    GC refactoring, remove "steps"

    simonmar authored
    The GC had a two-level structure, G generations each of T steps.
    Steps are for aging within a generation, mostly to avoid premature
    Measurements show that more than 2 steps is almost never worthwhile,
    and 1 step is usually worse than 2.  In theory fractional steps are
    possible, so the ideal number of steps is somewhere between 1 and 3.
    GHC's default has always been 2.
    We can implement 2 steps quite straightforwardly by having each block
    point to the generation to which objects in that block should be
    promoted, so blocks in the nursery point to generation 0, and blocks
    in gen 0 point to gen 1, and so on.
    This commit removes the explicit step structures, merging generations
    with steps, thus simplifying a lot of code.  Performance is
    unaffected.  The tunable number of steps is now gone, although it may
    be replaced in the future by a way to tune the aging in generation 0.
Commits on Dec 1, 2009
  1. @simonmar

    Make allocatePinned use local storage, and other refactorings

    simonmar authored
    This is a batch of refactoring to remove some of the GC's global
    state, as we move towards CPU-local GC.  
      - allocateLocal() now allocates large objects into the local
        nursery, rather than taking a global lock and allocating
        then in gen 0 step 0.
      - allocatePinned() was still allocating from global storage and
        taking a lock each time, now it uses local storage. 
        (mallocForeignPtrBytes should be faster with -threaded).
      - We had a gen 0 step 0, distinct from the nurseries, which are
        stored in a separate nurseries[] array.  This is slightly strange.
        I removed the g0s0 global that pointed to gen 0 step 0, and
        removed all uses of it.  I think now we don't use gen 0 step 0 at
        all, except possibly when there is only one generation.  Possibly
        more tidying up is needed here.
      - I removed the global allocate() function, and renamed
        allocateLocal() to allocate().
      - the alloc_blocks global is gone.  MAYBE_GC() and
        doYouWantToGC() now check the local nursery only.
Commits on Aug 5, 2009
  1. @simonmar

    profiling build fix

    simonmar authored
Commits on Aug 3, 2009
  1. @simonmar

    Common up two closure type -> string tables

    simonmar authored
    Also, use C99-style array initialisers
Commits on Aug 2, 2009
  1. @simonmar

    RTS tidyup sweep, first phase

    simonmar authored
    The first phase of this tidyup is focussed on the header files, and in
    particular making sure we are exposinng publicly exactly what we need
    to, and no more.
     - Rts.h now includes everything that the RTS exposes publicly,
       rather than a random subset of it.
     - Most of the public header files have moved into subdirectories, and
       many of them have been renamed.  But clients should not need to
       include any of the other headers directly, just #include the main
       public headers: Rts.h, HsFFI.h, RtsAPI.h.
     - All the headers needed for via-C compilation have moved into the
       stg subdirectory, which is self-contained.  Most of the headers for
       the rest of the RTS APIs have moved into the rts subdirectory.
     - I left MachDeps.h where it is, because it is so widely used in
       Haskell code.
     - I left a deprecated stub for RtsFlags.h in place.  The flag
       structures are now exposed by Rts.h.
     - Various internal APIs are no longer exposed by public header files.
     - Various bits of dead code and declarations have been removed
     - More gcc warnings are turned on, and the RTS code is more
     - More source files #include "PosixSource.h", and hence only use
       standard POSIX (1003.1c-1995) interfaces.
    There is a lot more tidying up still to do, this is just the first
    pass.  I also intend to standardise the names for external RTS APIs
    (e.g use the rts_ prefix consistently), and declare the internal APIs
    as hidden for shared libraries.
Commits on Nov 18, 2008
  1. @simonmar

    Add optional eager black-holing, with new flag -feager-blackholing

    simonmar authored
    Eager blackholing can improve parallel performance by reducing the
    chances that two threads perform the same computation.  However, it
    has a cost: one extra memory write per thunk entry.  
    To get the best results, any code which may be executed in parallel
    should be compiled with eager blackholing turned on.  But since
    there's a cost for sequential code, we make it optional and turn it on
    for the parallel package only.  It might be a good idea to compile
    applications (or modules) with parallel code in with
    ToDo: document -feager-blackholing.
Commits on Oct 3, 2008
  1. @simonmar
Commits on Jun 19, 2008
  1. @simonmar

    Fix up inlines for gcc 4.3

    simonmar authored
    gcc 4.3 emits warnings for static inline functions that its heuristics
    decided not to inline.  The workaround is to either mark appropriate
    functions as "hot" (a new attribute in gcc 4.3), or sometimes to use
    "extern inline" instead.
    With this fix I can validate with gcc 4.3 on Fedora 9.
Commits on Oct 12, 2007
  1. Add allocateInGen() for allocating in a specific generation, and clea…

    Simon Marlow authored
    Now allocate() is a synonym for allocateInGen().  
    I also made various cleanups: there is now less special-case code for
    supporting -G1 (two-space collection), and -G1 now works with
Commits on Oct 11, 2007
  1. Add a proper write barrier for MVars

    Simon Marlow authored
    Previously MVars were always on the mutable list of the old
    generation, which meant every MVar was visited during every minor GC.
    With lots of MVars hanging around, this gets expensive.  We addressed
    this problem for MUT_VARs (aka IORefs) a while ago, the solution is to
    use a traditional GC write-barrier when the object is modified.  This
    patch does the same thing for MVars.
    TVars are still done the old way, they could probably benefit from the
    same treatment too.
Commits on Aug 16, 2007
  1. @igfoo

    Compute max_era more simply

    igfoo authored
Commits on Jun 20, 2007
  1. remove debugging code accidentally left in

    Simon Marlow authored
Commits on Jun 13, 2007
  1. FIX #1418 (partially)

    Simon Marlow authored
    When the con_desc field of an info table was made into a relative
    reference, this had the side effect of making the profiling fields
    (closure_desc and closure_type) also relative, but only when compiling
    via C, and the heap profiler was still treating them as absolute,
    leading to crashes when profiling with -hd or -hy.
    This patch fixes up the story to be consistent: these fields really
    should be relative (otherwise we couldn't make shared versions of the
    profiling libraries), so I've made them relative and fixed up the RTS
    to know about this.
Commits on May 8, 2007
  1. FIX crash on exit with biographical profiling

    Simon Marlow authored
    Seems to be a bug introduced by code to free the memory allocated by
    the heap profiler.
  2. FIX profiling :-(

    Simon Marlow authored
Commits on Apr 27, 2007
  1. Basic heap profile support without -prof

    Simon Marlow authored
    Now that constructor info tables contain the name of the constructor,
    we can generate useful heap profiles without requiring the whole
    program and libraries to be compiled with -prof.  So now, "+RTS -hT"
    generates a heap profile for any program, dividing the profile by
    constructor.  It wouldn't be hard to add support for grouping
    constructors by module, or to restrict the profile to certain
    This means that for the first time we can get heap profiles for GHCi,
    which was previously impossible because the byte-code
    interpreter and linker don't work with -prof.
Commits on Feb 28, 2007
  1. Remove vectored returns.

    Simon Marlow authored
    We recently discovered that they aren't a win any more, and just cost
    code size.
Commits on Dec 15, 2006
  1. @igfoo
Commits on Nov 15, 2006
Commits on Oct 7, 2006
  1. STM invariants authored
Commits on Sep 29, 2006
  1. hp_slash_fix

    Ravi Nanavati authored
    Fix output of cost-centre stacks so that the slashes appear in the correct place
    Please include this patch in the 6.6 branch as well as HEAD
  2. rts_ccs_length

    Ravi Nanavati authored
    Add the -L RTS flag to control the length of the cost-centre stacks reported in 
    a heap profile.
    Please include this change in the 6.6 branch as well as HEAD
Commits on Sep 11, 2006
  1. @igfoo
Something went wrong with that request. Please try again.