diff options
author | Ömer Sinan Ağacan <omeragacan@gmail.com> | 2019-09-09 14:54:21 +0300 |
---|---|---|
committer | Ömer Sinan Ağacan <omeragacan@gmail.com> | 2019-09-11 11:14:58 +0300 |
commit | 7a5e3725a2d1da706c34582edac7bb147c7a5247 (patch) | |
tree | 29fb3bb4429700fc884ed42037a3fdd5513f73fd /rts/sm/GC.c | |
parent | 270fbe8512f04b6107755fa22bdec62205c0a567 (diff) | |
download | haskell-wip/osa1/min_payload_size.tar.gz |
Remove min payload size restriction from the compiler and RTSwip/osa1/min_payload_size
Previously we'd require every heap object to have at least one word
space in the payload. This was *incorrectly* documented as follows in
the source code: (now deleted)
Minimum closure sizes
This is the minimum number of words in the payload of a
heap-allocated closure, so that the closure has enough room to be
overwritten with a forwarding pointer during garbage collection.
This comment was wrong: the GC doesn't require a location in the
payload, forwarding pointers are made using the info table pointer
location.
The real reason why we needed a word in the payload is because
mark-compact collector allocates one bit per word in the heap for
bitmap, but needs two bits per object to work efficiently. Details are
explained in the new note Note [Mark bits in mark-compact collector] in
Compact.h.
We now allocate two bits in the bitmap per word and remove the
restriction. Heap objects can now have size 1, as demonstrated in the
updated tests.
Nofib results:
- 0.0% change in binary sizes and TotalMem
- "contaraints" now allocates -0.1% less. No other changes in
allocations.
- Runtime/Elapsed results are noisy and inconclusive
Diffstat (limited to 'rts/sm/GC.c')
-rw-r--r-- | rts/sm/GC.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/rts/sm/GC.c b/rts/sm/GC.c index 92a5e229a1..53c0d53e92 100644 --- a/rts/sm/GC.c +++ b/rts/sm/GC.c @@ -1414,17 +1414,14 @@ prepare_collected_gen (generation *gen) // for a compacted generation, we need to allocate the bitmap if (gen->mark) { - StgWord bitmap_size; // in bytes - bdescr *bitmap_bdescr; - StgWord *bitmap; - - bitmap_size = gen->n_old_blocks * BLOCK_SIZE / BITS_IN(W_); + // in bytes + StgWord bitmap_size = (gen->n_old_blocks * BLOCK_SIZE / BITS_IN(W_)) * 2; if (bitmap_size > 0) { - bitmap_bdescr = allocGroup((StgWord)BLOCK_ROUND_UP(bitmap_size) - / BLOCK_SIZE); + bdescr *bitmap_bdescr = + allocGroup((StgWord)BLOCK_ROUND_UP(bitmap_size) / BLOCK_SIZE); gen->bitmap = bitmap_bdescr; - bitmap = bitmap_bdescr->start; + StgWord *bitmap = bitmap_bdescr->start; debugTrace(DEBUG_gc, "bitmap_size: %d, bitmap: %p", bitmap_size, bitmap); @@ -1436,7 +1433,7 @@ prepare_collected_gen (generation *gen) // block descriptor. for (bd=gen->old_blocks; bd != NULL; bd = bd->link) { bd->u.bitmap = bitmap; - bitmap += BLOCK_SIZE_W / BITS_IN(W_); + bitmap += (BLOCK_SIZE_W / BITS_IN(W_)) * 2; // Also at this point we set the BF_MARKED flag // for this block. The invariant is that |