Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull - Cut ties with BindBind, no need for BuildR #2828

Merged
merged 1 commit into from
Feb 24, 2022

Conversation

diesalbla
Copy link
Contributor

@diesalbla diesalbla commented Feb 24, 2022

Description of changes

  • Modify Bind class to make the step into an abstract method.
  • Modify the BindBind class to make the references to the middle and end Bind objects mutable.
  • Modify the bindBindAux method (that applies the continuation) to cut the ties with the two Bind objects. That is, set both pointers to null. For an intuition as to why this is correct, it helps to think of a BindBind as a node in a stack of continuations, applied to the terminal result of a pull. Once a BindBind is applied, it should be popped and not used again.

Cutting this ties allows us to remove the use of the BuildR intermediate representation, for the Uncons and StepLeg case interpreters, without this causing the memory leak tests to fail.

Reasons

The motivation for these changes are several. On one hand, the BuildR is a bit of a hack to workaround a problem (the leak) not well understood. On the other hand, avoiding those continuations may shave some memory consumption. A smaller design motivation has always been to make the go function of the compile method sort of tail-recursive inside F. That is to say, in each recursive case the call to go is the last effect action.

Discussion

Removing the use of the intermediate BuildR and just passing recursively the handlers for Uncons and StepLeg has been tried before, such as in #2445 or #2196. However, this caused reports of memory leaks that were recorded in issues, and were fixed by reverting those changes, as done in #2394. Since each of those memory leak reports was recorded into a minimised IntegrationTest, there is some confidence that these changes would not cause new leaks.

We modify `Bind` class to make the `step` into an abstract method.

For the `BindBind` process, we modify the `bindBindAux` method
(for applying continuation) to cut ties to the two Bind objects.
An intuition for this is that a `BindBind` is just a node in a
stack of continuations, applied to the terminal result of a pull.
Once applied, the `BindBind` should not be used again.

Cutting this ties allows us to remove the use of the `BuildR`
intermediate representation, for the Uncons and StepLeg
case interpreters, without this causing the memory leaks tests
to fail.
@mpilquist mpilquist merged commit 11691a5 into typelevel:main Feb 24, 2022
@diesalbla diesalbla deleted the unwind_bind_bind branch February 26, 2022 03:33
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