mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-06 07:38:24 +00:00
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user