-
Notifications
You must be signed in to change notification settings - Fork 2.7k
fast path for incompatible deps #6919
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ec0ad71
fast path the 2 most common backtrack paths. Test say we don't need t…
Eh2406 c0be9ce
fast path one more problem
Eh2406 8080c98
add the original optimization in for good measure
Eh2406 49eaa13
add comments
Eh2406 fb786a1
skip the unneeded allocation
Eh2406 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
add the original optimization in for good measure
- Loading branch information
commit 8080c98a1d751a97e77dadbe65d3fce4aff6fc1e
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -288,6 +288,7 @@ fn activate_deps_loop( | |
| &cx, | ||
| registry, | ||
| &mut past_conflicting_activations, | ||
| &parent, | ||
| &dep, | ||
| &conflicting_activations, | ||
| ) { | ||
|
|
@@ -854,10 +855,11 @@ fn generalize_conflicting( | |
| cx: &Context, | ||
| registry: &mut RegistryQueryer<'_>, | ||
| past_conflicting_activations: &mut conflict_cache::ConflictCache, | ||
| parent: &Summary, | ||
| dep: &Dependency, | ||
| conflicting_activations: &ConflictMap, | ||
| ) -> Option<ConflictMap> { | ||
| if conflicting_activations.len() != 1 { | ||
| if conflicting_activations.is_empty() { | ||
| return None; | ||
| } | ||
| // We need to determine the `ContextAge` that this `conflicting_activations` will jump to, and why. | ||
|
|
@@ -869,6 +871,16 @@ fn generalize_conflicting( | |
| let backtrack_critical_reason: ConflictReason = | ||
| conflicting_activations[&backtrack_critical_id].clone(); | ||
|
|
||
| if cx | ||
| .parents | ||
| .is_path_from_to(&parent.package_id(), &backtrack_critical_id) | ||
| { | ||
| // We are a descendant of the trigger of the problem. | ||
| // The best generalization of this is to let things bubble up | ||
| // and let `backtrack_critical_id` figure this out. | ||
| return None; | ||
| } | ||
|
|
||
| // we will need to know the range of versions we can use | ||
| let our_candidates = registry | ||
| .query(dep) | ||
|
|
@@ -905,10 +917,6 @@ fn generalize_conflicting( | |
| None | ||
| }; | ||
|
|
||
| if !(our_activation_key.is_some() || our_link.is_some()) { | ||
| return None; | ||
| } | ||
|
|
||
| let our_candidates: HashSet<PackageId> = | ||
| our_candidates.iter().map(|our| our.package_id()).collect(); | ||
|
|
||
|
|
@@ -920,6 +928,9 @@ fn generalize_conflicting( | |
| }) | ||
| { | ||
| 'dep: for critical_parents_dep in critical_parents_deps.iter() { | ||
| // A dep is equivalent to one of the things it can resolve to. | ||
| // Thus, if all the things it can resolve to have already ben determined | ||
| // to be conflicting, then we can just say that we conflict with the parent. | ||
| let mut con = conflicting_activations.clone(); | ||
| con.remove(&backtrack_critical_id); | ||
| con.insert(*critical_parent, backtrack_critical_reason.clone()); | ||
|
|
@@ -928,6 +939,8 @@ fn generalize_conflicting( | |
| .query(critical_parents_dep) | ||
| .expect("an already used dep now error!?") | ||
| .iter() | ||
| .rev() | ||
| // the last one to be tried is the least likely to be in the cache, so start with that. | ||
| { | ||
| if (our_activation_key | ||
| .map_or(false, |our| other.package_id().as_activations_key() == our) | ||
|
|
@@ -950,9 +963,32 @@ fn generalize_conflicting( | |
| ) { | ||
| con.extend(conflicting.into_iter()); | ||
| continue; | ||
| } else { | ||
| continue 'dep; | ||
| } | ||
|
|
||
| if let Some(conflicting) = past_conflicting_activations.find( | ||
| dep, | ||
| &|id| { | ||
| if id == other.package_id() { | ||
| // we are imagining that we used other instead | ||
| Some(backtrack_critical_age) | ||
| } else { | ||
| cx.is_active(id).filter(|&age| | ||
| // we only care about things that are older then critical_age | ||
| age < backtrack_critical_age) | ||
| } | ||
| }, | ||
| Some(other.package_id()), | ||
| ) { | ||
| con.extend( | ||
| conflicting | ||
| .iter() | ||
| .filter(|(&id, _)| id != other.package_id()) | ||
| .map(|(&id, r)| (id, r.clone())), | ||
| ); | ||
| continue; | ||
| } | ||
|
|
||
| continue 'dep; | ||
|
||
| } | ||
|
|
||
| if cfg!(debug_assertions) { | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Maybe in need of some
rustfmthere?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.
I have fmt on save, but it seems to be some kind of fmt bug. If the comment is in the callback fmt will not move it.