Per-thread allocation counters and limits

Authored by Simon Marlow <marlowsd@gmail.com>.

Description

Per-thread allocation counters and limits

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.

Details

Committed
Simon Marlow <marlowsd@gmail.com>May 2 2014, 8:49 AM
Parents
rGHC34db5ccf52ec: Replace all #!/usr/bin/perl with #!/usr/bin/env perl
Branches
Unknown
Tags
Unknown