Commit 69001f54 authored by Ben Gamari's avatar Ben Gamari 🐢 Committed by Marge Bot

nonmoving: Clear segment bitmaps during sweep

Previously we would clear the bitmaps of segments which we are going to
sweep during the preparatory pause. However, this is unnecessary: the
existence of the mark epoch ensures that the sweep will correctly
identify non-reachable objects, even if we do not clear the bitmap.

We now defer clearing the bitmap to sweep, which happens concurrently
with mutation.
parent 8324f0b7
...@@ -374,7 +374,6 @@ memcount nonmoving_live_words = 0; ...@@ -374,7 +374,6 @@ memcount nonmoving_live_words = 0;
#if defined(THREADED_RTS) #if defined(THREADED_RTS)
static void* nonmovingConcurrentMark(void *mark_queue); static void* nonmovingConcurrentMark(void *mark_queue);
#endif #endif
static void nonmovingClearBitmap(struct NonmovingSegment *seg);
static void nonmovingMark_(MarkQueue *mark_queue, StgWeak **dead_weaks, StgTSO **resurrected_threads); static void nonmovingMark_(MarkQueue *mark_queue, StgWeak **dead_weaks, StgTSO **resurrected_threads);
static void nonmovingInitSegment(struct NonmovingSegment *seg, uint8_t log_block_size) static void nonmovingInitSegment(struct NonmovingSegment *seg, uint8_t log_block_size)
...@@ -681,7 +680,7 @@ void nonmovingAddCapabilities(uint32_t new_n_caps) ...@@ -681,7 +680,7 @@ void nonmovingAddCapabilities(uint32_t new_n_caps)
nonmovingHeap.n_caps = new_n_caps; nonmovingHeap.n_caps = new_n_caps;
} }
static inline void nonmovingClearBitmap(struct NonmovingSegment *seg) void nonmovingClearBitmap(struct NonmovingSegment *seg)
{ {
unsigned int n = nonmovingSegmentBlockCount(seg); unsigned int n = nonmovingSegmentBlockCount(seg);
memset(seg->bitmap, 0, n); memset(seg->bitmap, 0, n);
...@@ -715,13 +714,9 @@ static void nonmovingPrepareMark(void) ...@@ -715,13 +714,9 @@ static void nonmovingPrepareMark(void)
if (filled) { if (filled) {
struct NonmovingSegment *seg = filled; struct NonmovingSegment *seg = filled;
while (true) { while (true) {
n_filled++;
prefetchForRead(seg->link);
// Clear bitmap
prefetchForWrite(seg->link->bitmap);
nonmovingClearBitmap(seg);
// Set snapshot // Set snapshot
nonmovingSegmentInfo(seg)->next_free_snap = seg->next_free; nonmovingSegmentInfo(seg)->next_free_snap = seg->next_free;
n_filled++;
if (seg->link) if (seg->link)
seg = seg->link; seg = seg->link;
else else
......
...@@ -130,6 +130,7 @@ void nonmovingCollect(StgWeak **dead_weaks, ...@@ -130,6 +130,7 @@ void nonmovingCollect(StgWeak **dead_weaks,
void *nonmovingAllocate(Capability *cap, StgWord sz); void *nonmovingAllocate(Capability *cap, StgWord sz);
void nonmovingAddCapabilities(uint32_t new_n_caps); void nonmovingAddCapabilities(uint32_t new_n_caps);
void nonmovingPushFreeSegment(struct NonmovingSegment *seg); void nonmovingPushFreeSegment(struct NonmovingSegment *seg);
void nonmovingClearBitmap(struct NonmovingSegment *seg);
INLINE_HEADER struct NonmovingSegmentInfo *nonmovingSegmentInfo(struct NonmovingSegment *seg) { INLINE_HEADER struct NonmovingSegmentInfo *nonmovingSegmentInfo(struct NonmovingSegment *seg) {
......
...@@ -65,6 +65,7 @@ nonmovingSweepSegment(struct NonmovingSegment *seg) ...@@ -65,6 +65,7 @@ nonmovingSweepSegment(struct NonmovingSegment *seg)
} else { } else {
ASSERT(seg->next_free == 0); ASSERT(seg->next_free == 0);
ASSERT(nonmovingSegmentInfo(seg)->next_free_snap == 0); ASSERT(nonmovingSegmentInfo(seg)->next_free_snap == 0);
nonmovingClearBitmap(seg);
return SEGMENT_FREE; return SEGMENT_FREE;
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment