diff options
author | Simon Marlow <marlowsd@gmail.com> | 2014-05-04 20:27:42 +0100 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2014-05-04 20:28:58 +0100 |
commit | f0fcc41d755876a1b02d1c7c79f57515059f6417 (patch) | |
tree | 89cce0cfc61744b1c7b732619ea9de04f21fdcfe /libraries | |
parent | 5141baf76132fe0d8f88cfa0a62698cc3b37e48a (diff) | |
download | haskell-f0fcc41d755876a1b02d1c7c79f57515059f6417.tar.gz |
Revert "Per-thread allocation counters and limits"
Problems were found on 32-bit platforms, I'll commit again when I have a fix.
This reverts the following commits:
54b31f744848da872c7c6366dea840748e01b5cf
b0534f78a73f972e279eed4447a5687bd6a8308e
Diffstat (limited to 'libraries')
-rw-r--r-- | libraries/base/Control/Exception.hs | 1 | ||||
-rw-r--r-- | libraries/base/Control/Exception/Base.hs | 1 | ||||
-rw-r--r-- | libraries/base/GHC/Conc.lhs | 6 | ||||
-rw-r--r-- | libraries/base/GHC/Conc/Sync.lhs | 92 | ||||
-rw-r--r-- | libraries/base/GHC/IO/Exception.hs | 21 |
5 files changed, 6 insertions, 115 deletions
diff --git a/libraries/base/Control/Exception.hs b/libraries/base/Control/Exception.hs index e13a0e978b..7c019eb5ca 100644 --- a/libraries/base/Control/Exception.hs +++ b/libraries/base/Control/Exception.hs @@ -48,7 +48,6 @@ module Control.Exception ( NestedAtomically(..), BlockedIndefinitelyOnMVar(..), BlockedIndefinitelyOnSTM(..), - AllocationLimitExceeded(..), Deadlock(..), NoMethodError(..), PatternMatchFail(..), diff --git a/libraries/base/Control/Exception/Base.hs b/libraries/base/Control/Exception/Base.hs index be9f4e5e41..d8a0d9635f 100644 --- a/libraries/base/Control/Exception/Base.hs +++ b/libraries/base/Control/Exception/Base.hs @@ -31,7 +31,6 @@ module Control.Exception.Base ( NestedAtomically(..), BlockedIndefinitelyOnMVar(..), BlockedIndefinitelyOnSTM(..), - AllocationLimitExceeded(..), Deadlock(..), NoMethodError(..), PatternMatchFail(..), diff --git a/libraries/base/GHC/Conc.lhs b/libraries/base/GHC/Conc.lhs index 804fd1539d..1ba17f2912 100644 --- a/libraries/base/GHC/Conc.lhs +++ b/libraries/base/GHC/Conc.lhs @@ -60,12 +60,6 @@ module GHC.Conc , threadWaitWriteSTM , closeFdWith - -- * Allocation counter and limit - , setAllocationCounter - , getAllocationCounter - , enableAllocationLimit - , disableAllocationLimit - -- * TVars , STM(..) , atomically diff --git a/libraries/base/GHC/Conc/Sync.lhs b/libraries/base/GHC/Conc/Sync.lhs index 6d786f5530..ebb7226d09 100644 --- a/libraries/base/GHC/Conc/Sync.lhs +++ b/libraries/base/GHC/Conc/Sync.lhs @@ -61,12 +61,6 @@ module GHC.Conc.Sync , threadStatus , threadCapability - -- * Allocation counter and quota - , setAllocationCounter - , getAllocationCounter - , enableAllocationLimit - , disableAllocationLimit - -- * TVars , STM(..) , atomically @@ -183,92 +177,16 @@ instance Eq ThreadId where instance Ord ThreadId where compare = cmpThread --- | Every thread has an allocation counter that tracks how much --- memory has been allocated by the thread. The counter is --- initialized to zero, and 'setAllocationCounter' sets the current --- value. The allocation counter counts *down*, so in the absence of --- a call to 'setAllocationCounter' its value is the negation of the --- number of bytes of memory allocated by the thread. --- --- There are two things that you can do with this counter: --- --- * Use it as a simple profiling mechanism, with --- 'getAllocationCounter'. --- --- * Use it as a resource limit. See 'enableAllocationLimit'. --- --- Allocation accounting is accurate only to about 4Kbytes. --- -setAllocationCounter :: Int64 -> IO () -setAllocationCounter i = do - ThreadId t <- myThreadId - rts_setThreadAllocationCounter t i - --- | Return the current value of the allocation counter for the --- current thread. -getAllocationCounter :: IO Int64 -getAllocationCounter = do - ThreadId t <- myThreadId - rts_getThreadAllocationCounter t - --- | Enables the allocation counter to be treated as a limit for the --- current thread. When the allocation limit is enabled, if the --- allocation counter counts down below zero, the thread will be sent --- the 'AllocationLimitExceeded' asynchronous exception. When this --- happens, the counter is reinitialised (by default --- to 100K, but tunable with the @+RTS -xq@ option) so that it can handle --- the exception and perform any necessary clean up. If it exhausts --- this additional allowance, another 'AllocationLimitExceeded' exception --- is sent, and so forth. --- --- Note that memory allocation is unrelated to /live memory/, also --- known as /heap residency/. A thread can allocate a large amount of --- memory and retain anything between none and all of it. It is --- better to think of the allocation limit as a limit on --- /CPU time/, rather than a limit on memory. --- --- Compared to using timeouts, allocation limits don't count time --- spent blocked or in foreign calls. --- -enableAllocationLimit :: IO () -enableAllocationLimit = do - ThreadId t <- myThreadId - rts_enableThreadAllocationLimit t - --- | Disable allocation limit processing for the current thread. -disableAllocationLimit :: IO () -disableAllocationLimit = do - ThreadId t <- myThreadId - rts_disableThreadAllocationLimit t - --- We cannot do these operations safely on another thread, because on --- a 32-bit machine we cannot do atomic operations on a 64-bit value. --- Therefore, we only expose APIs that allow getting and setting the --- limit of the current thread. -foreign import ccall unsafe "rts_setThreadAllocationCounter" - rts_setThreadAllocationCounter :: ThreadId# -> Int64 -> IO () - -foreign import ccall unsafe "rts_getThreadAllocationCounter" - rts_getThreadAllocationCounter :: ThreadId# -> IO Int64 - -foreign import ccall unsafe "rts_enableThreadAllocationLimit" - rts_enableThreadAllocationLimit :: ThreadId# -> IO () - -foreign import ccall unsafe "rts_disableThreadAllocationLimit" - rts_disableThreadAllocationLimit :: ThreadId# -> IO () - {- | -Creates a new thread to run the 'IO' computation passed as the +Sparks off a new thread to run the 'IO' computation passed as the first argument, and returns the 'ThreadId' of the newly created thread. -The new thread will be a lightweight, /unbound/ thread. Foreign calls -made by this thread are not guaranteed to be made by any particular OS -thread; if you need foreign calls to be made by a particular OS -thread, then use 'Control.Concurrent.forkOS' instead. +The new thread will be a lightweight thread; if you want to use a foreign +library that uses thread-local storage, use 'Control.Concurrent.forkOS' instead. -The new thread inherits the /masked/ state of the parent (see -'Control.Exception.mask'). +GHC note: the new thread inherits the /masked/ state of the parent +(see 'Control.Exception.mask'). The newly created thread has an exception handler that discards the exceptions 'BlockedIndefinitelyOnMVar', 'BlockedIndefinitelyOnSTM', and diff --git a/libraries/base/GHC/IO/Exception.hs b/libraries/base/GHC/IO/Exception.hs index af9e7661e0..7f5bc4ef18 100644 --- a/libraries/base/GHC/IO/Exception.hs +++ b/libraries/base/GHC/IO/Exception.hs @@ -22,7 +22,6 @@ module GHC.IO.Exception ( BlockedIndefinitelyOnMVar(..), blockedIndefinitelyOnMVar, BlockedIndefinitelyOnSTM(..), blockedIndefinitelyOnSTM, Deadlock(..), - AllocationLimitExceeded(..), allocationLimitExceeded, AssertionFailed(..), SomeAsyncException(..), @@ -100,23 +99,6 @@ instance Show Deadlock where ----- --- |This thread has exceeded its allocation limit. See --- 'GHC.Conc.setAllocationCounter' and --- 'GHC.Conc.enableAllocationLimit'. -data AllocationLimitExceeded = AllocationLimitExceeded - deriving Typeable - -instance Exception AllocationLimitExceeded - -instance Show AllocationLimitExceeded where - showsPrec _ AllocationLimitExceeded = - showString "allocation limit exceeded" - -allocationLimitExceeded :: SomeException -- for the RTS -allocationLimitExceeded = toException AllocationLimitExceeded - ------ - -- |'assert' was applied to 'False'. data AssertionFailed = AssertionFailed String deriving Typeable @@ -193,8 +175,7 @@ data ArrayException instance Exception ArrayException --- for the RTS -stackOverflow, heapOverflow :: SomeException +stackOverflow, heapOverflow :: SomeException -- for the RTS stackOverflow = toException StackOverflow heapOverflow = toException HeapOverflow |