-
Notifications
You must be signed in to change notification settings - Fork 36
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
Track outdated priorities in a set #313
Conversation
pubgrub currently assumes that package priorities can only change when the derivations of a package change. In tracks the decision level range where derivations changed, and only updates decisions in this level. This assumption is incorrect for uv, where the priority doesn't depend on the range, but on specifiers and discovery order per package name, not per `DP::P`, which contains virtual packages, too. This change enables more flexible priority updating for uv now and for pubgrub generally in the future. Instead of updating all package priorities in a decision level range, we directly track the set of packages that need to be updated because we changed their derivations. This enables adding pushing priority updates from uv in our fork. Currently, packages that are removed from prioritization, those that need to be changed and those that are added are all treated the same way, there might be some optimization by telling them apart. This branch is based on dev...Eh2406:pubgrub:stop-prioritize.
@Eh2406 can you run the cargo perf numbers on this? on uv it's perf neutral with astral-sh/uv#10935 |
CodSpeed Instrumentation Performance ReportMerging #313 will improve performances by 6.38%Comparing Summary
Benchmarks breakdown
|
When the user's implementation breaks the contract about choose version, we now panic. This contract is trivial to enforce (`vs.contains(v)`), so an error path does not make sense. Fixes #239
src/internal/partial_solution.rs
Outdated
// Throw away all stored priority levels, And mark that they all need to be recomputed. | ||
self.prioritized_potential_packages.clear(); | ||
self.prioritize_decision_level = self.current_decision_level.0.saturating_sub(1) as usize; | ||
// Throw away all stored priority levels and mark them for recomputing |
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.
the code this comment refers to has been removed.
I just checked, no measurable difference on CPU time or memory usage for crates.io. So the question is is the code going to be easier to maintain this way? |
src/internal/partial_solution.rs
Outdated
@@ -62,8 +63,6 @@ pub(crate) struct PartialSolution<DP: DependencyProvider> { | |||
/// range. |
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.
The comet ending on this line is now out of date.
I find the set-based approach significantly easier to understand. |
Sounds logical to me too. |
It also looks faster in uv in a quick test (p = 1.18e-08):
|
pubgrub currently assumes that package priorities can only change when the derivations of a package change. In tracks the decision level range where derivations changed, and only updates decisions in this level.
This assumption is incorrect for uv, where the priority doesn't depend on the range, but on specifiers and discovery order per package name, not per
DP::P
, which contains virtual packages, too. This change enables more flexible priority updating for uv now and for pubgrub generally in the future.Instead of updating all package priorities in a decision level range, we directly track the set of packages that need to be updated because we changed their derivations. This enables adding pushing priority updates from uv in our fork.
Currently, packages that are removed from prioritization, those that need to be changed and those that are added are all treated the same way, there might be some optimization by telling them apart.
This branch is based on dev...Eh2406:pubgrub:stop-prioritize.
Half of #239, incidentally