summaryrefslogtreecommitdiff
path: root/includes/rts/Threads.h
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2014-04-28 16:55:47 +0100
committerSimon Marlow <marlowsd@gmail.com>2014-05-02 14:49:22 +0100
commitb0534f78a73f972e279eed4447a5687bd6a8308e (patch)
tree02d52756620bf27b9df9db45c57dacf55f190842 /includes/rts/Threads.h
parent34db5ccf52ec2a1b5e953c282d0c52a7fc82c02a (diff)
downloadhaskell-b0534f78a73f972e279eed4447a5687bd6a8308e.tar.gz
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.
Diffstat (limited to 'includes/rts/Threads.h')
-rw-r--r--includes/rts/Threads.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/includes/rts/Threads.h b/includes/rts/Threads.h
index da6f7a4add..f6264adfb9 100644
--- a/includes/rts/Threads.h
+++ b/includes/rts/Threads.h
@@ -42,8 +42,12 @@ StgRegTable * resumeThread (void *);
//
// Thread operations from Threads.c
//
-int cmp_thread (StgPtr tso1, StgPtr tso2);
-int rts_getThreadId (StgPtr tso);
+int cmp_thread (StgPtr tso1, StgPtr tso2);
+int rts_getThreadId (StgPtr tso);
+HsInt64 rts_getThreadAllocationCounter (StgPtr tso);
+void rts_setThreadAllocationCounter (StgPtr tso, HsInt64 i);
+void rts_enableThreadAllocationLimit (StgPtr tso);
+void rts_disableThreadAllocationLimit (StgPtr tso);
#if !defined(mingw32_HOST_OS)
pid_t forkProcess (HsStablePtr *entry);