summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2014-10-07 10:30:36 +0100
committerSimon Marlow <marlowsd@gmail.com>2014-11-25 14:37:26 +0000
commite22bc0dedb9e9da0176ad7ce4a74acbefedc7207 (patch)
tree8a8872279576edf6824c25bf31accd793d970fd8 /includes
parente159e08a5e1c1f9f7b6805f3f0775333104c3d6e (diff)
downloadhaskell-e22bc0dedb9e9da0176ad7ce4a74acbefedc7207.tar.gz
Make clearNursery free
Summary: clearNursery resets all the bd->free pointers of nursery blocks to make the blocks empty. In profiles we've seen clearNursery taking significant amounts of time particularly with large -N and -A values. This patch moves the work of clearNursery to the point at which we actually need the new block, thereby introducing an invariant that blocks to the right of the CurrentNursery pointer still need their bd->free pointer reset. This should make things faster overall, because we don't need to clear blocks that we don't use. Test Plan: validate Reviewers: AndreasVoellmy, ezyang, austin Subscribers: thomie, carter, ezyang, simonmar Differential Revision: https://phabricator.haskell.org/D318
Diffstat (limited to 'includes')
-rw-r--r--includes/rts/storage/GC.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/includes/rts/storage/GC.h b/includes/rts/storage/GC.h
index c171b67252..db71e951ea 100644
--- a/includes/rts/storage/GC.h
+++ b/includes/rts/storage/GC.h
@@ -66,6 +66,27 @@ typedef struct nursery_ {
memcount n_blocks;
} nursery;
+// Nursery invariants:
+//
+// - cap->r.rNursery points to the nursery for this capability
+//
+// - cap->r.rCurrentNursery points to the block in the nursery that we are
+// currently allocating into. While in Haskell the current heap pointer is
+// in Hp, outside Haskell it is stored in cap->r.rCurrentNursery->free.
+//
+// - the blocks *after* cap->rCurrentNursery in the chain are empty
+// (although their bd->free pointers have not been updated to
+// reflect that)
+//
+// - the blocks *before* cap->rCurrentNursery have been used. Except
+// for rCurrentAlloc.
+//
+// - cap->r.rCurrentAlloc is either NULL, or it points to a block in
+// the nursery *before* cap->r.rCurrentNursery.
+//
+// See also Note [allocation accounting] to understand how total
+// memory allocation is tracked.
+
typedef struct generation_ {
nat no; // generation number