-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
perf: cache comparison key for choosing the next package to resolve #10275
base: main
Are you sure you want to change the base?
Conversation
Reviewer's Guide by SourceryThis pull request optimizes the dependency resolution process by caching the comparison key used to determine the next dependency to resolve. It introduces a No diagrams generated as the changes look simple and do not need a visual representation. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey @radoering - I've reviewed your changes - here's some feedback:
Overall Comments:
- It might be worth exploring if
functools.lru_cache
would be a better fit thanfunctools.cache
here, given that the number of unique dependencies might be quite large.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟡 Complexity: 1 issue found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
183a6de
to
7fa43ef
Compare
The comparison key for choosing the next dependency to be resolved from the list of unsatisfied dependencies is calculated again and again until the dependency is chosen and removed from the list. Especially for dependencies, which have many dependencies themselves, calculating the comparison key can take some time. Therefore, it makes sense to cache the comparison key of each dependency.
The time for locking #10195 goes down from about 24 seconds to 20 seconds with this PR.
Since the
_get_min
function was a private function of_choose_next
, I had to move it for caching. I also updated the comments. (I did not change the logic.)Summary by Sourcery
Cache the comparison key used to determine the next package to resolve, improving performance.
Enhancements:
_get_min
function to enable caching of the comparison key.