-
-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Resolver: Parallelize the import resolution loop #158845
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
base: main
Are you sure you want to change the base?
Changes from all commits
6340b84
9feb227
a33f749
a45ba86
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -247,6 +247,33 @@ pub fn par_map<I: DynSend, T: IntoIterator<Item = I>, R: DynSend, C: FromIterato | |
| }) | ||
| } | ||
|
|
||
| pub fn par_filter_map<I: DynSend, T: IntoIterator<Item = I>, R: DynSend, C: FromIterator<R>>( | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. almost a mirror of
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we keep the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But ideally we'd do everything in place with |
||
| t: T, | ||
| map: impl Fn(I) -> Option<R> + DynSync + DynSend, | ||
| ) -> C { | ||
| parallel_guard(|guard| { | ||
| if let Some(proof) = mode::check_dyn_thread_safe() { | ||
| let map = proof.derive(map); | ||
|
|
||
| let mut items: Vec<(Option<I>, Option<Option<R>>)> = | ||
| t.into_iter().map(|i| (Some(i), None)).collect(); | ||
|
|
||
| par_slice( | ||
| &mut items, | ||
| guard, | ||
| |i| { | ||
| i.1 = Some(map(i.0.take().unwrap())); | ||
| }, | ||
| proof, | ||
| ); | ||
|
|
||
| items.into_iter().filter_map(|(_, r)| r.flatten()).collect() | ||
| } else { | ||
| t.into_iter().filter_map(|i| guard.run(|| map(i)).flatten()).collect() | ||
| } | ||
| }) | ||
| } | ||
|
|
||
| pub fn broadcast<R: DynSend>(op: impl Fn(usize) -> R + DynSync) -> Vec<R> { | ||
| if let Some(proof) = mode::check_dyn_thread_safe() { | ||
| let op = proof.derive(op); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -791,7 +791,8 @@ fn resolver_for_lowering_raw<'tcx>( | |
| &'tcx Steal<ast::Crate>, | ||
| &'tcx ty::ResolverGlobalCtxt, | ||
| ) { | ||
| let arenas = Resolver::arenas(); | ||
| let arenas = Resolver::new_arenas(); | ||
| let extern_arenas = Resolver::new_arenas(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I expected having new locked fields inside the existing
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, this was just to make it work. |
||
| let _ = tcx.registered_tools(()); // Uses `crate_for_resolver`. | ||
| let (krate, pre_configured_attrs) = tcx.crate_for_resolver(()).steal(); | ||
| let mut resolver = Resolver::new( | ||
|
|
@@ -800,6 +801,7 @@ fn resolver_for_lowering_raw<'tcx>( | |
| krate.spans.inner_span, | ||
| krate.spans.inject_use_span, | ||
| &arenas, | ||
| &extern_arenas, | ||
| ); | ||
| let krate = configure_and_expand(krate, &pre_configured_attrs, &mut resolver); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
These track callers can cause unintended regressions in other places in the compiler, it's better to benchmark this change separately.
View changes since the review