-
Couldn't load subscription status.
- Fork 149
Description
reflex-plattform contains a patch for the garbage collector of ghcjs to fix a "leak" in the implementation of FastWeak/FastWeakBag. Before we can migrate production systems to ghc 9.X we need to either forward port that patch, ideally upstreaming it for all ghc backends, determine that it is unnecessary or find another workaround. @ryantrinkle has started on upstreaming this at https://gitlab.haskell.org/ghc/ghc/-/issues/25373, where the core problem is described:
- Every value pointed to by a waiting finalizer is alive.
- On GC all dangling Weak pointers will be GC’d, but their finalizer will only be run after the GC phase.
- Thus, all Weak pointers retained by a finalizer can only be cleared in the next GC step.
- This leads to problem with chains of Weak pointers:
Specifically, in the case of a doubly-linked list which is weak in one direction, cleaning up a list of n items takes O(n) full GC+finalization cycles. Since certain workloads (particularly FRP) construct long chains like this frequently, in a steady state, this results in memory effectively leaking - even though it will eventually get cleaned up, garbage can be created much faster than it gets cleaned up.
My goal is to
- write a reproducer for the problem as it occurs in reflex.
- Figure out whether we can find a workaround or demonstrate that a patch like the above will be needed.