-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Refactor HIR item-like traversal (part 1) #95655
Conversation
Some changes occurred in src/tools/clippy. cc @rust-lang/clippy |
(rust-highfive has picked a reviewer for you, use r? to override) |
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.
Thanks @kckeiks. This is a good start. I have a few remarks/questions.
|
||
fn visit_item(&mut self, item: &'hir Item<'hir>) { | ||
self.items.push(item.item_id()); | ||
intravisit::walk_item(self, item) |
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.
Could you keep filling submodules
? It may prove useful to implement for_each_module
.
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.
Yes, I can update this method. I think for_each_module
is already there.
rust/compiler/rustc_middle/src/hir/map/mod.rs
Line 679 in 6a9080b
pub fn for_each_module(self, f: impl Fn(LocalDefId)) { |
Actually, that one starts from the root mod so I may have to do something else here.
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 mean: for_each_module
currently walks hir_module_items
recursively. par_for_each_module
does this in recursive form. Having hir_crate_items.submodules
as the list of all the modules in the crate will make those two functions simple loops over it.
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 see what you mean. I will update for_each_module
now that I'm collecting modules.
|
||
return ModuleItems { | ||
submodules: submodules.into_boxed_slice(), | ||
items: items.into_boxed_slice(), |
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.
Reading the code, I'm not sure that items
starts with CRATE_DEF_ID
. It should.
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.
Now that you mention it, looking at where the walk begins in walk_toplevel_module
, it seems like CRATE_DEF_ID
does not get added to items
. Am I reading that right?
This comment has been minimized.
This comment has been minimized.
b474ba5
to
292637c
Compare
This comment has been minimized.
This comment has been minimized.
292637c
to
4db16f0
Compare
This comment has been minimized.
This comment has been minimized.
4db16f0
to
f213ed6
Compare
This comment has been minimized.
This comment has been minimized.
f213ed6
to
6ef0f16
Compare
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 6ef0f16d6da22d5508d0299f654368ce263ff2f2 with merge 269a8ae2d5d9ee215834795c69b97483f02b20bf... |
☀️ Try build successful - checks-actions |
Queued 269a8ae2d5d9ee215834795c69b97483f02b20bf with parent f262ca1, future comparison URL. |
Finished benchmarking commit (269a8ae2d5d9ee215834795c69b97483f02b20bf): comparison url. Summary:
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR led to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Footnotes |
@cjgillot I imagine that the performance regression comes from the traversal that the visitor does in |
36043bf
to
88108bd
Compare
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 88108bd with merge be80ce668cc66c6c4748400d6a1d7fe5bf440436... |
☀️ Try build successful - checks-actions |
Queued be80ce668cc66c6c4748400d6a1d7fe5bf440436 with parent f7b4824, future comparison URL. |
Finished benchmarking commit (be80ce668cc66c6c4748400d6a1d7fe5bf440436): comparison url. Summary:
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Footnotes |
This PR is the first in a series that should significantly reduce full-HIR traversal by queries. This is expected to bring improvements to incremental compilation, by decreasing result invalidation. This first PR creates the infrastructure for this change, as a new query @bors r+ |
📌 Commit 88108bd has been approved by |
☀️ Test successful - checks-actions |
Finished benchmarking commit (edba282): comparison url. Summary:
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression Footnotes |
… r=cjgillot Refactor HIR item-like traversal (part 1) Issue rust-lang#95004 - Create hir_crate_items query which traverses tcx.hir_crate(()).owners to return a hir::ModuleItems - use tcx.hir_crate_items in tcx.hir().items() to return an iterator of hir::ItemId - use tcx.hir_crate_items to introduce a tcx.hir().par_items(impl Fn(hir::ItemId)) to traverse all items in parallel; Signed-off-by: Miguel Guarniz <[email protected]> cc `@cjgillot`
Issue #95004
Signed-off-by: Miguel Guarniz [email protected]
cc @cjgillot