implementing GC semantics for WeakPointer more like ghc#24
implementing GC semantics for WeakPointer more like ghc#24alios wants to merge 5 commits intoghcjs:masterfrom alios:master
Conversation
src/gc.js
Outdated
There was a problem hiding this comment.
The paper says "If the weak pointer object is reachable then tombstone it.". But if I set w.val to null I get runtime errors.
|
hmm, I don't think it's quite correct, I can't get any finalizers to run. |
|
I now have a fix that makes it behave like GHC on all test cases that I have. I'll test it with a few more to be sure, and hopefully push this later today. Other test cases welcome too. |
|
Thank you very much!!! Haven't been able to test it yet, but closing down this pull request. |
|
@luite Just tried my reactive banana code again agains the most recent master. (also rebuild most recent ghcjs and everything) ... The effect stays the same - the FRP code stops after ~2sec. So the gc seems to still eat/finalize things required. Will try to extract a minimum example tomorrow. |
|
Great, thanks. I saw that some other test case in the testsuite related to this also fails now. Perhaps I messed up somewhere. More testcases are always good for this rts-heavy type of problem, the type system doesn't help much here. |
|
opened a new pull request: #25. |
Working on a sodium FRP based code compiled with ghcjs, I noticed that roughly after ~2sec the event propagations seemd to stop. This was reported here ghcjs/ghcjs#296 a year ago, and most recently also discussed in an issue of the sodium repo here: SodiumFRP/sodium#70.
In the meantime I have switched from sodium to reactive-banana, as sodium for haskell was deprecated by @the-real-blackh in favor of reactive-banana. reactive-banana show the very same effect. Stops after ~2 seconds, which is basicly when the GC goes around.
From the more recent ticke a discussion between @luite (ghcjs) and @HeinrichApfelmus (reactive-banana) spawned here on redit which encouraged me to read the original paper on this topic: Stretching the storage manager: weak pointers and stable names in Haskell
In this pull request I tried to implement the semantics as close to the Paper I could. Although this is the first time for me working on the ghcjs rts, so especialy the semantics within the GC are new for me, so I propably produced memory leaks or other stuff. And there is probably also space for optimization, because my first goal was to implement it as close to the paper above as possible.
I also have not done any testing or benchmarking, although my sodium/reactive-banana code now keeps working and does not die after the GC has hit.
In the meantime there also exists an issue in the reactive-banana issue tracker here: HeinrichApfelmus/reactive-banana#109