[Git][ghc/ghc][wip/gc/aligned-block-allocation] 4 commits: Disallow allocating megablocks, update tests
Ben Gamari
gitlab at gitlab.haskell.org
Wed Jun 19 00:32:14 UTC 2019
Ben Gamari pushed to branch wip/gc/aligned-block-allocation at Glasgow Haskell Compiler / GHC
Commits:
f3191083 by Ömer Sinan Ağacan at 2019-06-19T00:32:01Z
Disallow allocating megablocks, update tests
- - - - -
67cbec4a by Ömer Sinan Ağacan at 2019-06-19T00:32:01Z
Fix lint errors
- - - - -
59d32a99 by Ömer Sinan Ağacan at 2019-06-19T00:32:01Z
Use allocLargeChunkOnNode to reduce splitting
- - - - -
ead67e40 by Ömer Sinan Ağacan at 2019-06-19T00:32:01Z
Allow allocating megablocks in allocAlignedGroupOnNode
This is currently broken because freeGroup assumes integral number of
megablocks when freeing megablocks but we try to split the megablocks
returned by allocLargeChunkOnNode to smaller groups and free the rest.
- - - - -
2 changed files:
- rts/sm/BlockAlloc.c
- testsuite/tests/rts/testblockalloc.c
Changes:
=====================================
rts/sm/BlockAlloc.c
=====================================
@@ -511,10 +511,11 @@ allocAlignedGroupOnNode (uint32_t node, W_ n)
uint32_t num_blocks = 2*n - 1;
W_ group_size = n * BLOCK_SIZE;
- // It's okay if we get a group larger than what we request; we will end up
- // splitting it anyways. By using allocLargeChunk we reduce the potential
- // for fragmentation.
- bdescr *bd = allocLargeChunkOnNode(node, num_blocks, 3*n);
+ // To reduce splitting and fragmentation we use allocLargeChunkOnNode here.
+ bdescr *bd = allocLargeChunkOnNode(node, num_blocks, num_blocks*3);
+
+ // We may allocate more than num_blocks, so update it
+ num_blocks = bd->blocks;
// slop on the low side
W_ slop_low = 0;
@@ -532,7 +533,7 @@ allocAlignedGroupOnNode (uint32_t node, W_ n)
ASSERT(slop_low_blocks + slop_high_blocks + n == num_blocks);
-#ifdef DEBUG
+#if defined(DEBUG)
checkFreeListSanity();
W_ free_before = countFreeList();
#endif
@@ -542,7 +543,7 @@ allocAlignedGroupOnNode (uint32_t node, W_ n)
ASSERT(countBlocks(bd) == num_blocks - slop_low_blocks);
}
-#ifdef DEBUG
+#if defined(DEBUG)
ASSERT(countFreeList() == free_before + slop_low_blocks);
checkFreeListSanity();
#endif
@@ -550,7 +551,7 @@ allocAlignedGroupOnNode (uint32_t node, W_ n)
// At this point the bd should be aligned, but we may have slop on the high side
ASSERT((uintptr_t)bd->start % group_size == 0);
-#ifdef DEBUG
+#if defined(DEBUG)
free_before = countFreeList();
#endif
@@ -559,7 +560,7 @@ allocAlignedGroupOnNode (uint32_t node, W_ n)
ASSERT(bd->blocks == n);
}
-#ifdef DEBUG
+#if defined(DEBUG)
ASSERT(countFreeList() == free_before + slop_high_blocks);
checkFreeListSanity();
#endif
=====================================
testsuite/tests/rts/testblockalloc.c
=====================================
@@ -80,8 +80,9 @@ static void test_aligned_alloc(void)
for (int j=0; j < ARRSIZE; j++)
{
int b = (rand() % MAXALLOC) + 1;
+ if (b == 0) { b = 1; }
a[j] = allocAlignedGroupOnNode(0, b);
- if ((uintptr_t) a[j]->start % b != 0)
+ if ((((W_)(a[j]->start)) % (b*BLOCK_SIZE)) != 0)
{
barf("%p is not aligned to allocation size %d", a[j], b);
}
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/compare/d2577711ce077d6887f0b7046e863148da270643...ead67e400308d2ee48f20dd99e33ea03d906e3b2
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/compare/d2577711ce077d6887f0b7046e863148da270643...ead67e400308d2ee48f20dd99e33ea03d906e3b2
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20190618/360489a1/attachment-0001.html>
More information about the ghc-commits
mailing list