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

Return incompatibility from conflict & Allow backtracking to before a specific package #36

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

konstin
Copy link
Member

@konstin konstin commented Dec 12, 2024

Background reading: astral-sh/uv#8157

I'll link the PR on the uv side with all the details once it's up, it contains a walkthrough.

This adds two features to pubgrub:

Return incompatibility from conflict: Whenever we either discard a version due to its dependencies or perform conflict resolution, we return the last conflict that led to discarding them. In uv, we use this to re-prioritize and backtrack when a package decision accumulated to many conflicts. Using the incompatibilities directly from pubgrub makes this efficient.

Allow backtracking to before a specific package: Once we identified a pair of conflicting packages, we want to switch their priorities. This requires backtracking to before the decision for the earlier of the two packages was made. On the uv side, we change the priorities to make sure we take a different path on the next attempt. We allow attempting to backtrack on packages that were not decided yet to avoid the caller from making the duplicative check: At the time when the see incompatibilities caused by them, they are not necessarily decided.

Best reviewed commit-by-commit.

Copy link

codspeed-hq bot commented Dec 12, 2024

CodSpeed Performance Report

Congrats! CodSpeed is installed 🎉

🆕 6 new benchmarks were detected.

You will start to see performance impacts in the reports once the benchmarks are run from your default branch.

Detected benchmarks

  • backtracking_disjoint_versions (2.3 s)
  • backtracking_ranges (2 s)
  • backtracking_singletons (4.3 s)
  • large_case_u16_NumberVersion.ron (21.4 ms)
  • sudoku-easy (3.8 ms)
  • sudoku-hard (3.9 ms)

@konstin konstin changed the title Return Id<DP::P> over &ID<DP::P> Return incompatibility from conflict & Allow backtracking to before a specific package Dec 12, 2024
Whenever we either discard a version due to its dependencies or perform conflict resolution, we return the last conflict that led to discarding them. In uv, we use this to re-prioritize and backtrack when a package decision accumulated to many conflicts.
This allows discarding a previously made decision if it turned out to be a bad decision, even if all options with this decisions have not yet been rejected.

We allow attempting to backtrack on packages that were not decided yet to avoid the caller from making the duplicative check.
Allow introspecting which packages are to be decided. uv currently uses this for (trace) logging in the resolver.
@konstin konstin force-pushed the konsti/backtrack-package branch from 036aab4 to 251e93b Compare December 13, 2024 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant