-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Description
What's the problem this feature will solve?
Pip's dependency resolution process, particularly in complex backtracking scenarios, currently faces performance issues due to repetitive calculations, leading to O(n^2) complexity. This issue arises when checking if a "name" is part of a cause but also hinders the implementation of more complex checks, as they would slow down simple backtracking scenarios.
Describe the solution you'd like
The solution proposes adding a new abstract method, filter_unsatisfied_names, in resolvelib, to be implemented by Pip. This method is designed to work alongside the existing get_preference method, refining the backtracking process during dependency resolution.
filter_unsatisfied_namespre-filters unsatisfied names before they are processed byget_preference.- Unlike
get_preference, which is called once for each name,filter_unsatisfied_namesis called only once per backtracking round. - All unsatisfied names are provided to
filter_unsatisfied_names, in contrast toget_preference, which receives one name at a time. - Hence
filter_unsatisfied_namesis able to short-circuiting checks. - And
filter_unsatisfied_namescan determine if multiple names are important to backtrack on simultaneously.
Alternative Solutions
- Enhancing
get_preference: Improvements to this method could offer some benefits, but it would struggle to enable complex backtracks without imposing performance penalties on simple backtracks. - Implementing Caching: While caching can reduce redundant work, it might lead to increased memory usage and added complexity.
Additional context
I am not tied to the name filter_unsatisfied_names or even to this specific approach, as long as it's possible to filter unsatisfied names more than one at a time.
A PR is open on the resolvelib side, but it is unlikely to ever be merged without buy-in from Pip maintainers: sarugaku/resolvelib#145
Code of Conduct
- I agree to follow the PSF Code of Conduct.