Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- performGC :: IO ()
- performMajorGC :: IO ()
- performMinorGC :: IO ()
- setAllocationCounter :: Int64 -> IO ()
- getAllocationCounter :: IO Int64
- enableAllocationLimit :: IO ()
- disableAllocationLimit :: IO ()
- getNumCapabilities :: IO Int
- setNumCapabilities :: Int -> IO ()
- numSparks :: IO Int
- runSparks :: IO ()
- getNumProcessors :: IO Int
- getUncaughtExceptionHandler :: IO (SomeException -> IO ())
- setUncaughtExceptionHandler :: (SomeException -> IO ()) -> IO ()
- data EventManager
- getSystemEventManager :: IO (Maybe EventManager)
- new :: IO EventManager
- data Event
- evtRead :: Event
- evtWrite :: Event
- type IOCallback = FdKey -> Event -> IO ()
- data FdKey
- data Lifetime
- registerFd :: EventManager -> IOCallback -> Fd -> Event -> Lifetime -> IO FdKey
- unregisterFd :: EventManager -> FdKey -> IO ()
- unregisterFd_ :: EventManager -> FdKey -> IO Bool
- closeFd :: EventManager -> (Fd -> IO ()) -> Fd -> IO ()
- data TimerManager
- type TimeoutCallback = IO ()
- data TimeoutKey
- registerTimeout :: TimerManager -> Int -> TimeoutCallback -> IO TimeoutKey
- updateTimeout :: TimerManager -> TimeoutKey -> Int -> IO ()
- unregisterTimeout :: TimerManager -> TimeoutKey -> IO ()
- data RTSStats = RTSStats {
- gcs :: Word32
- major_gcs :: Word32
- allocated_bytes :: Word64
- max_live_bytes :: Word64
- max_large_objects_bytes :: Word64
- max_compact_bytes :: Word64
- max_slop_bytes :: Word64
- max_mem_in_use_bytes :: Word64
- cumulative_live_bytes :: Word64
- copied_bytes :: Word64
- par_copied_bytes :: Word64
- cumulative_par_max_copied_bytes :: Word64
- cumulative_par_balanced_copied_bytes :: Word64
- mutator_cpu_ns :: RtsTime
- mutator_elapsed_ns :: RtsTime
- gc_cpu_ns :: RtsTime
- gc_elapsed_ns :: RtsTime
- cpu_ns :: RtsTime
- elapsed_ns :: RtsTime
- gc :: GCDetails
- data GCDetails = GCDetails {
- gcdetails_gen :: Word32
- gcdetails_threads :: Word32
- gcdetails_allocated_bytes :: Word64
- gcdetails_live_bytes :: Word64
- gcdetails_large_objects_bytes :: Word64
- gcdetails_compact_bytes :: Word64
- gcdetails_slop_bytes :: Word64
- gcdetails_mem_in_use_bytes :: Word64
- gcdetails_copied_bytes :: Word64
- gcdetails_par_max_copied_bytes :: Word64
- gcdetails_par_balanced_copied_bytes :: Word64
- gcdetails_sync_elapsed_ns :: RtsTime
- gcdetails_cpu_ns :: RtsTime
- gcdetails_elapsed_ns :: RtsTime
- type RtsTime = Int64
- getRTSStats :: IO RTSStats
- getRTSStatsEnabled :: IO Bool
- storeLoadBarrier :: IO ()
- loadLoadBarrier :: IO ()
- writeBarrier :: IO ()
Garbage collection
performMajorGC :: IO () #
Triggers an immediate major garbage collection.
Since: base-4.7.0.0
performMinorGC :: IO () #
Triggers an immediate minor garbage collection.
Since: base-4.7.0.0
Allocation counter and limits
setAllocationCounter :: Int64 -> IO () #
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.
Since: base-4.8.0.0
getAllocationCounter :: IO Int64 #
Return the current value of the allocation counter for the current thread.
Since: base-4.8.0.0
enableAllocationLimit :: IO () #
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. Like other asynchronous exceptions, the
AllocationLimitExceeded
exception is deferred while the thread is inside
mask
or an exception handler in catch
.
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.
Since: base-4.8.0.0
disableAllocationLimit :: IO () #
Disable allocation limit processing for the current thread.
Since: base-4.8.0.0
Capabilities
getNumCapabilities :: IO Int #
Returns the number of Haskell threads that can run truly
simultaneously (on separate physical processors) at any given time. To change
this value, use setNumCapabilities
.
Since: base-4.4.0.0
setNumCapabilities :: Int -> IO () #
Set the number of Haskell threads that can run truly simultaneously
(on separate physical processors) at any given time. The number
passed to forkOn
is interpreted modulo this value. The initial
value is given by the +RTS -N
runtime flag.
This is also the number of threads that will participate in parallel garbage collection. It is strongly recommended that the number of capabilities is not set larger than the number of physical processor cores, and it may often be beneficial to leave one or more cores free to avoid contention with other processes in the machine.
Since: base-4.5.0.0
Spark pool
Processors
getNumProcessors :: IO Int #
Returns the number of CPUs that the machine has
Since: base-4.5.0.0
Uncaught exception handler
getUncaughtExceptionHandler :: IO (SomeException -> IO ()) #
setUncaughtExceptionHandler :: (SomeException -> IO ()) -> IO () #
Event manager
data EventManager #
The event manager state.
new :: IO EventManager #
Create a new event manager.
An I/O event.
type IOCallback = FdKey -> Event -> IO () #
Callback invoked on I/O events.
A file descriptor registration cookie.
The lifetime of an event registration.
Since: base-4.8.1.0
registerFd :: EventManager -> IOCallback -> Fd -> Event -> Lifetime -> IO FdKey #
registerFd mgr cb fd evs lt
registers interest in the events evs
on the file descriptor fd
for lifetime lt
. cb
is called for
each event that occurs. Returns a cookie that can be handed to
unregisterFd
.
unregisterFd :: EventManager -> FdKey -> IO () #
Drop a previous file descriptor registration.
unregisterFd_ :: EventManager -> FdKey -> IO Bool #
Drop a previous file descriptor registration, without waking the event manager thread. The return value indicates whether the event manager ought to be woken.
closeFd :: EventManager -> (Fd -> IO ()) -> Fd -> IO () #
Close a file descriptor in a race-safe way.
Timer manager
data TimerManager #
The event manager state.
type TimeoutCallback = IO () #
Callback invoked on timeout events.
data TimeoutKey #
A timeout registration cookie.
Instances
Eq TimeoutKey | |
Defined in GHC.Event.TimerManager (==) :: TimeoutKey -> TimeoutKey -> Bool # (/=) :: TimeoutKey -> TimeoutKey -> Bool # |
registerTimeout :: TimerManager -> Int -> TimeoutCallback -> IO TimeoutKey #
Register a timeout in the given number of microseconds. The
returned TimeoutKey
can be used to later unregister or update the
timeout. The timeout is automatically unregistered after the given
time has passed.
updateTimeout :: TimerManager -> TimeoutKey -> Int -> IO () #
Update an active timeout to fire in the given number of microseconds.
unregisterTimeout :: TimerManager -> TimeoutKey -> IO () #
Unregister an active timeout.
Runtime stats
Statistics about runtime activity since the start of the
program. This is a mirror of the C struct RTSStats
in RtsAPI.h
Since: base-4.10.0.0
RTSStats | |
|
Statistics about a single GC. This is a mirror of the C struct
GCDetails
in RtsAPI.h
, with the field prefixed with gc_
to
avoid collisions with RTSStats
.
GCDetails | |
|
getRTSStats :: IO RTSStats #
Get current runtime system statistics.
Since: base-4.10.0.0
getRTSStatsEnabled :: IO Bool #
Returns whether GC stats have been enabled (with +RTS -T
, for example).
Since: base-4.10.0.0
Memory barriers
storeLoadBarrier :: IO () #
Memory barrier implemented by the GHC rts (see SMP.h). storeLoadBarrier :: IO ()
Memory barrier implemented by the GHC rts (see SMP.h). loadLoadBarrier :: IO ()
Memory barrier implemented by the GHC rts (see SMP.h). writeBarrier :: IO ()
Memory barrier implemented by the GHC rts (see SMP.h).
loadLoadBarrier :: IO () #
Memory barrier implemented by the GHC rts (see SMP.h).
writeBarrier :: IO () #
Memory barrier implemented by the GHC rts (see SMP.h).