Skip to content

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

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

Merged
merged 2 commits into from
Sep 12, 2016

Conversation

grayjay
Copy link
Collaborator

@grayjay grayjay commented Sep 12, 2016

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

@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
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
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
Copy link
Contributor

dcoutts commented Sep 12, 2016

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
Member

LGTM as well.

@grayjay
Copy link
Collaborator Author

grayjay commented Sep 12, 2016

Thanks!

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

ezyang commented Sep 12, 2016

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