Pull - Cut ties with BindBind, no need for BuildR #2828
Merged
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
Bind
class to make thestep
into an abstract method.BindBind
class to make the references to the middle and end Bind objects mutable.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 aBindBind
as a node in a stack of continuations, applied to the terminal result of a pull. Once aBindBind
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 theUncons
andStepLeg
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 thego
function of the compile method sort of tail-recursive insideF
. That is to say, in each recursive case the call togo
is the last effect action.Discussion
Removing the use of the intermediate
BuildR
and just passing recursively the handlers forUncons
andStepLeg
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.