Skip to content
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

Optimize Backtracking in Pip's Dependency Resolution By Prioritizing Direct Conflicts #12498

Open
1 task done
notatallshaw opened this issue Jan 30, 2024 · 0 comments · May be fixed by #12499
Open
1 task done

Optimize Backtracking in Pip's Dependency Resolution By Prioritizing Direct Conflicts #12498

notatallshaw opened this issue Jan 30, 2024 · 0 comments · May be fixed by #12499
Labels
S: needs triage Issues/PRs that need to be triaged type: feature request Request for a new feature

Comments

@notatallshaw
Copy link
Contributor

notatallshaw commented Jan 30, 2024

What's the problem this feature will solve?

In complex dependency resolution scenarios, Pip currently may backtrack inefficiently, especially when dealing with direct conflicts in requirements that are just a subset of the possible "causes" that resolvelib returns.

This inefficiency leads to real-world users experiencing "ResolutionTooDeep" issues, as seen in #12489, #12430, and #12395.

Describe the solution you'd like

The proposed solution introduces optimization techniques in Pip's dependency resolution logic that prioritize backtracking on direct conflicts. Inspired by conflict-driven clause learning (CDCL), a core principle in SAT solvers, the aim is to focus on the most impactful conflicts during backtracking, thereby streamlining the resolution process.

The goal is to prioritize direct conflicts within the identified backtracking causes. For example, two candidates specifying conflicting requirements like "numpy<2" and "numpy>2", or a situation where one candidate requires "pandas<2" while another has parent "pandas 2.1.0". By focusing on these critical conflict points, the algorithm can more efficiently navigate the complex dependency graph.

Alternative Solutions

Let users continue attempting to resolve these issues themselves by sufficiently restricting requirements. However, this approach provides very little context or help on how to do so effectively.

Additional context

Depends on #12497 to be performant for simple backtracking cases

Code of Conduct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S: needs triage Issues/PRs that need to be triaged type: feature request Request for a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant