diff --git a/lib/system/yrc.nim b/lib/system/yrc.nim index 46dd891a5d123..aa11f4099be9c 100644 --- a/lib/system/yrc.nim +++ b/lib/system/yrc.nim @@ -1700,8 +1700,10 @@ proc finishCollection() = # defer a rescan for. The counter is global, so with N collectors in play # it ticks N times per heap-collection; scale the period to match, or each # thread re-traces its whole old generation every YrcEpochLen/N collections. + let inPlay = slotsInPlay() + {.assume: 1 <= inPlay.} # gParSlots starts at 1 and only grows if atomicAddFetch(addr gCollectionCounter, 1, ATOMIC_RELAXED) mod - (YrcEpochLen * slotsInPlay()) == 0: + (YrcEpochLen * inPlay) == 0: discard atomicAddFetch(addr gEpoch, 1, ATOMIC_RELAXED) {.assume: 0 <= gCtx.slot and gCtx.slot < MaxPar.} # claimed in startCollection if gCtx.parked: