Skip to content

Conversation

@notatallshaw
Copy link
Collaborator

@notatallshaw notatallshaw commented May 28, 2025

Fixes #180

This implements #180 (comment) with a ratio of 10%.

10% is somewhat arbitrary, but the general idea is optimistic backtracking is supposed to be much faster than regular backtracking, and therefore if it is taking a significant amount of the remaining rounds left it is probably going down the wrong path. I tried several different numbers for different max rounds on real world and synthetic cases and found between 5% and 20% tended to work best.

While not intended to be changed I have made _OPTIMISTIC_BACKJUMPING_RATIO a global as an easy way for a knowledgeable motivated resolvelib user to pick a different ratio (in particular they may want to pick 0 or 1).

I have added additional tests that fail without optimistic backjumping (i.e. optimistic backjumping is able to skip over certain requirements that regular backjumping can not). I also test turning off optimistic backjumping to make sure all other tests pass without it.

(Note: I have collected recent problematic real world examples in pypa/pip#13281 and have been documenting them in problematic.toml).

@notatallshaw notatallshaw force-pushed the optimistic-backjumping-with-cutoff branch from 301c1a7 to 814715c Compare May 28, 2025 13:42
@notatallshaw notatallshaw force-pushed the optimistic-backjumping-with-cutoff branch from 814715c to 207da9a Compare May 28, 2025 13:48
@notatallshaw
Copy link
Collaborator Author

@uranusjr @frostming Any thoughts on this?

In an ideal world I would like to see this released so I can get this in the next version of Python. It solves 7 out of the 8 ResolutionTooDeep errors I have open against pip without introducing any new ones.

@frostming
Copy link
Member

LGTM from my side.

@notatallshaw
Copy link
Collaborator Author

Okay, I'll leave it a few more days if anyone else wants to comment and then merge.

And then look to do a release shortly there after (not sure if I have required permissions, will open an issue for a release and we'll see how it goes).

@notatallshaw notatallshaw merged commit f1bdb2b into sarugaku:main Jun 14, 2025
14 checks passed
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.

Back jump doesn't do well in some cases

2 participants