diff options
author | Simon Marlow <marlowsd@gmail.com> | 2016-04-09 20:45:50 +0100 |
---|---|---|
committer | Simon Marlow <smarlow@fb.com> | 2016-05-04 05:30:30 -0700 |
commit | 76ee260778991367b8dbf07ecf7afd31f826c824 (patch) | |
tree | fbddddf878413dab3c01abf8108c26d2bd20db4c /rts/Capability.h | |
parent | f9d93751126e58fb990335095e02fd81a3595fde (diff) | |
download | haskell-76ee260778991367b8dbf07ecf7afd31f826c824.tar.gz |
Allow limiting the number of GC threads (+RTS -qn<n>)
This allows the GC to use fewer threads than the number of capabilities.
At each GC, we choose some of the capabilities to be "idle", which means
that the thread running on that capability (if any) will sleep for the
duration of the GC, and the other threads will do its work. We choose
capabilities that are already idle (if any) to be the idle capabilities.
The idea is that this helps in the following situation:
* We want to use a large -N value so as to make use of hyperthreaded
cores
* We use a large heap size, so GC is infrequent
* But we don't want to use all -N threads in the GC, because that
thrashes the memory too much.
See docs for usage.
Diffstat (limited to 'rts/Capability.h')
-rw-r--r-- | rts/Capability.h | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/rts/Capability.h b/rts/Capability.h index 561d369a21..85fb53457d 100644 --- a/rts/Capability.h +++ b/rts/Capability.h @@ -225,14 +225,29 @@ INLINE_HEADER void releaseCapability_ (Capability* cap STG_UNUSED, extern Capability **capabilities; // +// Types of global synchronisation +// +typedef enum { + SYNC_OTHER, + SYNC_GC_SEQ, + SYNC_GC_PAR +} SyncType; + +// +// Details about a global synchronisation +// +typedef struct { + SyncType type; // The kind of synchronisation + rtsBool *idle; + Task *task; // The Task performing the sync +} PendingSync; + +// // Indicates that the RTS wants to synchronise all the Capabilities // for some reason. All Capabilities should stop and return to the // scheduler. // -#define SYNC_GC_SEQ 1 -#define SYNC_GC_PAR 2 -#define SYNC_OTHER 3 -extern volatile StgWord pending_sync; +extern PendingSync * volatile pending_sync; // Acquires a capability at a return point. If *cap is non-NULL, then // this is taken as a preference for the Capability we wish to |