diff options
author | Simon Marlow <marlowsd@gmail.com> | 2011-12-13 13:09:46 +0000 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2011-12-15 15:48:54 +0000 |
commit | 9bae79159d3cb5cbb6491711341aa9b07d703ae6 (patch) | |
tree | 4aa767f2a58d4d42637dc999ab469dd2dd07db19 /rts/Capability.h | |
parent | dff852b1b65d07a4a400d3f20c854172c8fcecaf (diff) | |
download | haskell-9bae79159d3cb5cbb6491711341aa9b07d703ae6.tar.gz |
Support for reducing the number of Capabilities with setNumCapabilities
This patch allows setNumCapabilities to /reduce/ the number of active
capabilities as well as increase it. This is particularly tricky to
do, because a Capability is a large data structure and ties into the
rest of the system in many ways. Trying to clean it all up would be
extremely error prone.
So instead, the solution is to mark the extra capabilities as
"disabled". This has the following consequences:
- threads on a disabled capability are migrated away by the
scheduler loop
- disabled capabilities do not participate in GC
(see scheduleDoGC())
- No spark threads are created on this capability
(see scheduleActivateSpark())
- We do not attempt to migrate threads *to* a disabled
capability (see schedulePushWork()).
So a disabled capability should do no work, and does not participate
in GC, although it remains alive in other respects. For example, a
blocked thread might wake up on a disabled capability, and it will get
quickly migrated to a live capability. A disabled capability can
still initiate GC if necessary. Indeed, it turns out to be hard to
migrate bound threads, so we wait until the next GC to do this (see
comments for details).
Diffstat (limited to 'rts/Capability.h')
-rw-r--r-- | rts/Capability.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/rts/Capability.h b/rts/Capability.h index f60adf9de4..91b4567186 100644 --- a/rts/Capability.h +++ b/rts/Capability.h @@ -49,6 +49,8 @@ struct Capability_ { // Has there been any activity on this Capability since the last GC? nat idle; + rtsBool disabled; + // The run queue. The Task owning this Capability has exclusive // access to its run queue, so can wake up threads without // taking a lock, and the common path through the scheduler is @@ -197,6 +199,8 @@ INLINE_HEADER void releaseCapability_ (Capability* cap STG_UNUSED, // declared in includes/rts/Threads.h: // extern nat n_capabilities; +extern nat enabled_capabilities; + // Array of all the capabilities // extern Capability *capabilities; |