-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Use new narrow requirement selection
resolvelib api to reduce cost of resolution
#13253
base: main
Are you sure you want to change the base?
Conversation
6040f02
to
0f6c25f
Compare
0f6c25f
to
86a46e0
Compare
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.
LGTM. One typo in a variable name.
Note - I've only desk checked this, I don't have any useful examples of resolutions to test it against.
Unfortunately the user who raised #10621 never provided a reproducible example, which was the initial report that led to making this API. But, I will test this branch against all scenarios in Pip-Resolution-Scenarios-and-Benchmarks, which includes popular resolutions and known difficult resolutions, before merging. |
…rement_selection`-resolvelib-API-to-speed-up-resolution
resolvelib 1.1 introduced a new API for providers:
narrow_requirement_selection
.narrow_requirement_selection
is very similar toget_preference
but it is only called once per round whereasget_preference
is called for the number of unsatisfied requirements there are in that round, which can be arbitrarily large.In short
narrow_requirement_selection
allows the provider to narrow what requirements, by their identifiers, are considered forget_preference
, reducing the cost of getting a preference, if it only returns 1 identifier then callingget_preference
is skipped altogether.Pip has two obvious preferences in it's current
get_preference
that can be moved tonarrow_requirement_selection
:REQUIRES_PYTHON_IDENTIFIER
- Should always be considered immediately, this skips checking all other preferences if this identifier is presentnarrow_requirement_selection
identifying backtrack causes costs O(n+b) and the cost is completely removed in getting the preference