Pull - Cut ties with BindBind, no need for BuildR#2828
Merged
mpilquist merged 1 commit intotypelevel:mainfrom Feb 24, 2022
Merged
Pull - Cut ties with BindBind, no need for BuildR#2828mpilquist merged 1 commit intotypelevel:mainfrom
mpilquist merged 1 commit intotypelevel:mainfrom
Conversation
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.
27179b6 to
f63dd03
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of changes
Bindclass to make thestepinto an abstract method.BindBindclass to make the references to the middle and end Bind objects mutable.bindBindAuxmethod (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 aBindBindas a node in a stack of continuations, applied to the terminal result of a pull. Once aBindBindis applied, it should be popped and not used again.Cutting this ties allows us to remove the use of the
BuildRintermediate representation, for theUnconsandStepLegcase interpreters, without this causing the memory leak tests to fail.Reasons
The motivation for these changes are several. On one hand, the
BuildRis 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 thegofunction of the compile method sort of tail-recursive insideF. That is to say, in each recursive case the call togois the last effect action.Discussion
Removing the use of the intermediate
BuildRand just passing recursively the handlers forUnconsandStepLeghas 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.