Skip to content

Commit 845f76f

Browse files
committed
re-enable scheduler thread local collections
This was a space leak. These local collections appear to have been disabled as part of the entanglement management effort a few years ago (specifically, in commit 4b4d1ce, which was then carried through to commit 51c658c more recently during the PCall implementation effort). Scheduler threads live at hierarchical heap depth 1, with the "global" heap immediately above as a shared ancestor. Interpreting this whole system as a disentangled heap hierarchy, we can perform scheduler-thread-local GC in the same way we would a leaf collection.
1 parent 7578624 commit 845f76f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

basis-library/schedulers/spork/Scheduler.sml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,7 @@ struct
12081208
let
12091209
val mySchedThread = Thread.current ()
12101210
val _ = HH.setDepth (mySchedThread, 1)
1211-
val _ = HH.setMinLocalCollectionDepth (mySchedThread, 2)
1211+
val _ = HH.setMinLocalCollectionDepth (mySchedThread, 1)
12121212

12131213
val myId = myWorkerId ()
12141214
val myRand = SimpleRandom.rand myId
@@ -1230,7 +1230,8 @@ struct
12301230
let
12311231
fun loop tries =
12321232
if tries = P * 100 then
1233-
( IdleTimer.tick ()
1233+
( MLton.GC.collect ()
1234+
; IdleTimer.tick ()
12341235
; traceSchedSleepEnter ()
12351236
; OS.Process.sleep (Time.fromNanoseconds (LargeInt.fromInt (P * 100)))
12361237
; traceSchedSleepLeave ()

0 commit comments

Comments
 (0)