[commit: ghc] master: initGroup: only initialize the first and last blocks of a group (74a00bc)
git at git.haskell.org
git at git.haskell.org
Wed Jul 15 19:22:10 UTC 2015
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/74a00bc8f96069f7205f091a02f3c571362f9522/ghc
>---------------------------------------------------------------
commit 74a00bc8f96069f7205f091a02f3c571362f9522
Author: Simon Marlow <marlowsd at gmail.com>
Date: Wed Jul 15 12:57:18 2015 +0100
initGroup: only initialize the first and last blocks of a group
Summary: Initialising the whole group is expensive and unnecessary.
Test Plan: validate
Reviewers: austin, bgamari, rwbarton
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D1071
>---------------------------------------------------------------
74a00bc8f96069f7205f091a02f3c571362f9522
rts/sm/BlockAlloc.c | 26 +++++++++++---------------
1 file changed, 11 insertions(+), 15 deletions(-)
diff --git a/rts/sm/BlockAlloc.c b/rts/sm/BlockAlloc.c
index 81cf0c4..c2a5913 100644
--- a/rts/sm/BlockAlloc.c
+++ b/rts/sm/BlockAlloc.c
@@ -183,23 +183,19 @@ void initBlockAllocator(void)
STATIC_INLINE void
initGroup(bdescr *head)
{
- bdescr *bd;
- W_ i, n;
-
- // If this block group fits in a single megablock, initialize
- // all of the block descriptors. Otherwise, initialize *only*
- // the first block descriptor, since for large allocations we don't
- // need to give the invariant that Bdescr(p) is valid for any p in the
- // block group. (This is because it is impossible to do, as the
- // block descriptor table for the second mblock will get overwritten
- // by contiguous user data.)
- n = head->blocks > BLOCKS_PER_MBLOCK ? 1 : head->blocks;
head->free = head->start;
head->link = NULL;
- for (i=1, bd = head+1; i < n; i++, bd++) {
- bd->free = 0;
- bd->blocks = 0;
- bd->link = head;
+
+ // If this is a block group (but not a megablock group), we
+ // make the last block of the group point to the head. This is used
+ // when coalescing blocks in freeGroup(). We don't do this for
+ // megablock groups because blocks in the second and subsequent
+ // mblocks don't have bdescrs; freeing these is handled in a
+ // different way by free_mblock_group().
+ if (head->blocks > 1 && head->blocks <= BLOCKS_PER_MBLOCK) {
+ bdescr *last = head + head->blocks-1;
+ last->blocks = 0;
+ last->link = head;
}
}
More information about the ghc-commits
mailing list