From f3d07ff114d6b9d06e8998b024c66bbde9aa1669 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Tue, 24 Feb 2026 11:12:28 +0100 Subject: [PATCH] YRC: fixes typo (#25541) Unrelated CI failures. --- lib/system/yrc.nim | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/system/yrc.nim b/lib/system/yrc.nim index 00b5d0f76e..29b6f70ef4 100644 --- a/lib/system/yrc.nim +++ b/lib/system/yrc.nim @@ -417,7 +417,8 @@ proc collectCycles() = cfprintf(cstderr, "[collectCycles] begin\n") yrcCollectorLock: mergePendingRoots() - if roots.len >= RootsThreshold and mayRunCycleCollect(): + if roots.len >= rootsThreshold and mayRunCycleCollect(): + let nRoots = roots.len var j: GcEnv init j.traceStack collectCyclesBacon(j, 0) @@ -434,8 +435,11 @@ proc collectCycles() = elif rootsThreshold < high(int) div 4: rootsThreshold = (if rootsThreshold <= 0: defaultThreshold else: rootsThreshold) rootsThreshold = rootsThreshold div 2 +% rootsThreshold - # Cap growth so threshold doesn't grow without bound when we rarely free cycles - #rootsThreshold = min(rootsThreshold, defaultThreshold *% 16) + # Cost-aware: if this run was expensive (large graph), raise threshold more so we don't run again too soon + if j.touched > nRoots *% 4: + rootsThreshold = rootsThreshold div 2 +% rootsThreshold + rootsThreshold = min(rootsThreshold, defaultThreshold *% 16) + rootsThreshold = min(rootsThreshold, nRoots *% 2) when logOrc: cfprintf(cstderr, "[collectCycles] end; freed %ld new threshold %ld\n", j.freed, rootsThreshold) when defined(nimOrcStats):