Repository navigation
Add 'WeightedPSQ' and use it to sort package, flag, and stanza choices. - #3594
Conversation
|
@GrayJay, thanks for your PR! By analyzing the annotation information on this pull request, we identified @kosmikus, @edsko and @martinvlk to be potential reviewers |
|
Let me be the grumpy code reviewer:
But I'm all for defining data structures we need. |
|
@GrayJay Looks promising so far. It doesn't seem to have any negative performance impact afaics. |
|
Thanks. I moved @kosmikus How do you want to proceed? Should I open a new PR with just |
|
I cleaned it up, added tests, and added documentation with asymptotics, similar to D.Compat.Graph. It's ready for review. I'd like to clean up the history before it is merged, though. |
| filter :: (v -> Bool) -> WeightedPSQ k w v -> WeightedPSQ k w v | ||
| filter p (WeightedPSQ xs) = WeightedPSQ (L.filter (p . triple_3) xs) | ||
|
|
||
| -- | /O(N)/. |
There was a problem hiding this comment.
Ouch! Should there be a TODO here to track the length separately? (Or maybe there's a good reason not to do it eagerly related to laziness?)
There was a problem hiding this comment.
length is actually no longer called. I think it was used by --reorder-goals, which now uses degree to avoid traversing the whole list. Calling length there had a significant impact on performance because it was called on the children of every available goal choice after the children were filtered with an expensive predicate. I'll remove it.
be60f86 to
8a7eb35
Compare
|
I was done working on it, but I wasn't sure if @kosmikus wanted to take another look. |
|
Let's merge then, if @kosmikus dislikes something he can always revert. |
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.
I split this out from #2917 because the data structure is also needed for goal-scoring (#3488).
WeightedPSQassociates weights with choices in the search tree. This PR usesWeightedPSQfor package, flag, and stanza choices andPSQfor goal choices, but eventually all choices should useWeightedPSQ. There are a few TODOs in the code./cc @kosmikus
EDIT: This PR uses
[Double]as the weight type to avoid changing the behavior of the solver.