Skip to content

Fix a space leak in package preferences (part of issue #3824). - #3826

Merged
sebright merged 2 commits into
haskell:masterfrom
sebright:preferences-space-leak
Sep 12, 2016
Merged

sebright merged 2 commits into
haskell:masterfrom
sebright:preferences-space-leak

Conversation

@sebright

Copy link
Copy Markdown
Collaborator

The space leak was introduced in #3594. #3594 added a new variable,
sortedVersions, to sort the subtrees under package choice nodes in the search
tree. However, sortedVersions referenced the subtrees and caused them to be
retained when it was not used. This commit forces evaluation of
sortedVersions.

The space leak was introduced in haskell#3594. haskell#3594 added a new variable,
sortedVersions, to sort the subtrees under package choice nodes in the search
tree. However, sortedVersions referenced the subtrees and caused them to be
retained when it was not used. This commit forces evaluation of
sortedVersions.
@mention-bot

Copy link
Copy Markdown

@GrayJay, thanks for your PR! By analyzing the annotation information on this pull request, we identified @kosmikus, @edsko and @BardurArantsson to be potential reviewers

-- Evaluate the children's versions before evaluating any of the
-- subtrees, so that 'versions' doesn't hold onto all of the
-- subtrees (referenced by cs) and cause a space leak.
(elemsToWhnf versions `seq`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess you can simplify this a little by forcing the sortedVersions and thus not having to define versions separately from sortedVersions.

Once versions are forced, then evaluating the result of the list sort doesn't force or retain any more, it's just a rearrangement of the (already forced) versions.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I had forced versions separately to avoid sorting the list unnecessarily. I don't think that was needed, though, because sortedVersions is almost always evaluated eventually (which is probably why this bug didn't show up sooner). I applied your suggestion.

@dcoutts

dcoutts commented Sep 12, 2016

Copy link
Copy Markdown
Contributor

Good catch and I agree the patch does what you say it does, and I'll believe you that it fixes the leak :-)

Just a minor simplification suggestion.

@23Skidoo

Copy link
Copy Markdown
Member

LGTM as well.

@sebright

Copy link
Copy Markdown
Collaborator Author

Thanks!

@sebright
sebright merged commit 01ce086 into haskell:master Sep 12, 2016
@sebright
sebright deleted the preferences-space-leak branch September 12, 2016 05:48
@ezyang

ezyang commented Sep 12, 2016

Copy link
Copy Markdown
Contributor

Thank you! (Someday we'll have regression tests for this sort of thing...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants