summaryrefslogtreecommitdiff
path: root/rts/Task.h
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2016-04-09 20:45:50 +0100
committerSimon Marlow <smarlow@fb.com>2016-05-04 05:30:30 -0700
commit76ee260778991367b8dbf07ecf7afd31f826c824 (patch)
treefbddddf878413dab3c01abf8108c26d2bd20db4c /rts/Task.h
parentf9d93751126e58fb990335095e02fd81a3595fde (diff)
downloadhaskell-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/Task.h')
-rw-r--r--rts/Task.h20
1 files changed, 9 insertions, 11 deletions
diff --git a/rts/Task.h b/rts/Task.h
index bcf456d270..209df49ddb 100644
--- a/rts/Task.h
+++ b/rts/Task.h
@@ -125,18 +125,16 @@ typedef struct Task_ {
rtsBool wakeup;
#endif
- // This points to the Capability that the Task "belongs" to. If
- // the Task owns a Capability, then task->cap points to it. If
- // the task does not own a Capability, then either (a) if the task
- // is a worker, then task->cap points to the Capability it belongs
- // to, or (b) it is returning from a foreign call, then task->cap
- // points to the Capability with the returning_worker queue that this
- // this Task is on.
+ // If the task owns a Capability, task->cap points to it. (occasionally a
+ // task may own multiple capabilities, in which case task->cap may point to
+ // any of them. We must be careful to set task->cap to the appropriate one
+ // when using Capability APIs.)
//
- // When a task goes to sleep, it may be migrated to a different
- // Capability. Hence, we always check task->cap on wakeup. To
- // syncrhonise between the migrater and the migratee, task->lock
- // must be held when modifying task->cap.
+ // If the task is a worker, task->cap points to the Capability on which it
+ // is queued.
+ //
+ // If the task is in an unsafe foreign call, then task->cap can be used to
+ // retrieve the capability (see rts_unsafeGetMyCapability()).
struct Capability_ *cap;
// The current top-of-stack InCall