Skip to content

Commit 3da6f54

Browse files
authored
Revert "relax assertion involving pg->nold to reflect that it may be a bit inaccurate with parallel marking (#50466)"
This reverts commit 8e877cb.
1 parent ffe1a07 commit 3da6f54

File tree

1 file changed

+14
-21
lines changed

1 file changed

+14
-21
lines changed

src/gc.c

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ STATIC_INLINE void gc_setmark_pool_(jl_ptls_t ptls, jl_taggedvalue_t *o,
854854
if (mark_mode == GC_OLD_MARKED) {
855855
ptls->gc_cache.perm_scanned_bytes += page->osize;
856856
static_assert(sizeof(_Atomic(uint16_t)) == sizeof(page->nold), "");
857-
page->nold++;
857+
jl_atomic_fetch_add_relaxed((_Atomic(uint16_t)*)&page->nold, 1);
858858
}
859859
else {
860860
ptls->gc_cache.scanned_bytes += page->osize;
@@ -1377,27 +1377,20 @@ static jl_taggedvalue_t **gc_sweep_page(jl_gc_pool_t *p, jl_gc_pagemeta_t **allo
13771377
nfree = (GC_PAGE_SZ - GC_PAGE_OFFSET) / osize;
13781378
goto done;
13791379
}
1380-
// note that `pg->nold` may not be accurate with multithreaded marking since
1381-
// two threads may race when trying to set the mark bit in `gc_try_setmark_tag`.
1382-
// We're basically losing a bit of precision in the sweep phase at the cost of
1383-
// making the mark phase considerably cheaper.
1384-
// See issue #50419
1385-
if (jl_n_markthreads == 0) {
1386-
// For quick sweep, we might be able to skip the page if the page doesn't
1387-
// have any young live cell before marking.
1388-
if (!sweep_full && !pg->has_young) {
1389-
assert(!prev_sweep_full || pg->prev_nold >= pg->nold);
1390-
if (!prev_sweep_full || pg->prev_nold == pg->nold) {
1391-
// the position of the freelist begin/end in this page
1392-
// is stored in its metadata
1393-
if (pg->fl_begin_offset != (uint16_t)-1) {
1394-
*pfl = page_pfl_beg(pg);
1395-
pfl = (jl_taggedvalue_t**)page_pfl_end(pg);
1396-
}
1397-
freedall = 0;
1398-
nfree = pg->nfree;
1399-
goto done;
1380+
// For quick sweep, we might be able to skip the page if the page doesn't
1381+
// have any young live cell before marking.
1382+
if (!sweep_full && !pg->has_young) {
1383+
assert(!prev_sweep_full || pg->prev_nold >= pg->nold);
1384+
if (!prev_sweep_full || pg->prev_nold == pg->nold) {
1385+
// the position of the freelist begin/end in this page
1386+
// is stored in its metadata
1387+
if (pg->fl_begin_offset != (uint16_t)-1) {
1388+
*pfl = page_pfl_beg(pg);
1389+
pfl = (jl_taggedvalue_t**)page_pfl_end(pg);
14001390
}
1391+
freedall = 0;
1392+
nfree = pg->nfree;
1393+
goto done;
14011394
}
14021395
}
14031396

0 commit comments

Comments
 (0)