Solver: Deduplicate LinkGroup's potential conflict set #3267
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.
This commit stores the potential conflict set in a set instead of a list. The deduplication prevents a
LinkGroup
from growing exponentially when it is merged with itself multiple times.This is one reason that the solver quickcheck test (#3245) ran out of memory, though the problem doesn't seem likely to occur with real packages. Here is a simplified version of the test case: grayjay@5297f3a. I didn't include it in the PR because it only fails when the solver handles goals in a specific order, and that order seems to depend on a bug.
EDIT: The bug is #3268.
After the solver links
2.C
to0.C-1.0.0
and chooses+flagA
for2.C-1.0.0
, it needs to merge theLinkGroup
s of the dependencies introduced byflagA
with theLinkGroup
s of the corresponding packages that are qualified with0
.flagA
introduces a dependency onD-3
multiple times. For the first dependency, the solver merges0.D
and2.D
'sLinkGroup
s. For each of the remaining dependencies onD-3
, the solver merges the new link group with itself. The fieldlgBlame :: [Var QPN]
doubles in length each time.Complete log from a run that included this PR: