-
Notifications
You must be signed in to change notification settings - Fork 1
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
A faster InstalledFirst policy (remake of #55) #65
Conversation
I'll address comments from #55 here as well. |
From #55 (comment)
This is indeed to make the code simpler and faster since we are pushing and removing from the priority queue tens of thousands of times for a reasonably sized problem. Given our recent discussion from #62, I will think about how to cheaply split this up to support different behaviors at runtime. |
ded746e
to
7031f85
Compare
@cournape I found it difficult to split the functionality apart cleanly, but hopefully this is something like what you had in mind 💭 |
So #68 updates the original Since this PR preserves that policy as |
@@ -82,12 +140,16 @@ def _group_packages_by_name(self, decision_set): | |||
|
|||
def _handle_empty_decision_set(self, assignments, clauses): | |||
# TODO inefficient and verbose | |||
|
|||
# The assignments with value None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this comment is redundant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These comments are here because it took me quite a while to understand what this policy was doing. For someone who knows the code base, they do not add much value. I'll remove them now.
assigned_ids = set(assignments.keys()) - unassigned_ids | ||
|
||
# Magnitude is literal, sign is Truthiness |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
@cournape ready for re-review. |
This PR is getting dismantled and broken into at least two, maybe more. |
This is a remake of the second half of #55.
This PR introduces a Policy that provides "installed first" behavior to the dependency solver, as well as a few helper classes.
Benchmarks are in issue #52.
It is implemented as a giant priority queue where the priorities split into three bands, in order from highest to lowest:
Within each group, packages are ordered descending by version, such that newer packages are tried first.
I'm currently using the notion that version objects are always comparable to define an ordering over all packages and assign priorities based on that, rather than grouping packages by name. In addition to being fast, easy to write, and easy to understand, it leads to a few interesting properties:
Things it does
curl-7.3.0
comes well beforeBiggus-0.7.0
.pep8 1.4.6
thenscipy 0.15.0
thenpep8 0.6.1
,>=
request #42,clause
literals and still be quite fast.To see this play out, there's a
PolicyLogger
class that is currently wrappingInstalledFirstPolicy
and keeping track of things.Things it doesn't do
clause
instances themselves,If this is suitable, I would think that this closes #42 and #52.