Skip to content

implementing GC semantics for WeakPointer more like ghc#24

Closed
alios wants to merge 5 commits intoghcjs:masterfrom
alios:master
Closed

implementing GC semantics for WeakPointer more like ghc#24
alios wants to merge 5 commits intoghcjs:masterfrom
alios:master

Conversation

@alios
Copy link

@alios alios commented Oct 8, 2015

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

alios referenced this pull request in HeinrichApfelmus/reactive-banana Oct 8, 2015
src/gc.js Outdated
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@luite
Copy link
Member

luite commented Oct 10, 2015

hmm, I don't think it's quite correct, I can't get any finalizers to run.

@luite
Copy link
Member

luite commented Oct 12, 2015

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.

@alios
Copy link
Author

alios commented Oct 16, 2015

Thank you very much!!! Haven't been able to test it yet, but closing down this pull request.

@alios alios closed this Oct 16, 2015
@alios alios reopened this Oct 16, 2015
@alios
Copy link
Author

alios commented Oct 16, 2015

@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.

@luite
Copy link
Member

luite commented Oct 16, 2015

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.

@alios
Copy link
Author

alios commented Oct 17, 2015

opened a new pull request: #25.
with that reactive-banana works again for me.

@alios alios closed this Oct 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants