• Simon Marlow's avatar
    Per-thread allocation counters and limits · b0534f78
    Simon Marlow authored
    This tracks the amount of memory allocation by each thread in a
    counter stored in the TSO.  Optionally, when the counter drops below
    zero (it counts down), the thread can be sent an asynchronous
    exception: AllocationLimitExceeded.  When this happens, given a small
    additional limit so that it can handle the exception.  See
    documentation in GHC.Conc for more details.
    
    Allocation limits are similar to timeouts, but
    
      - timeouts use real time, not CPU time.  Allocation limits do not
        count anything while the thread is blocked or in foreign code.
    
      - timeouts don't re-trigger if the thread catches the exception,
        allocation limits do.
    
      - timeouts can catch non-allocating loops, if you use
        -fno-omit-yields.  This doesn't work for allocation limits.
    
    I couldn't measure any impact on benchmarks with these changes, even
    for nofib/smp.
    b0534f78
RaiseAsync.h 2.03 KB