Skip to content
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

Avoid invoking the hir_crate query to traverse the HIR #88435

Merged
merged 5 commits into from
Sep 6, 2021

Conversation

cjgillot
Copy link
Contributor

Walking the HIR tree is done using the hir_crate query. However, this is unnecessary, since hir_owner(CRATE_DEF_ID) provides the same information. Since depending on hir_crate forces dependents to always be executed, this leads to unnecessary work.

By splitting HIR and attributes visits, we can avoid an edge to hir_crate when trying to visit the HIR tree.

@rust-highfive
Copy link
Collaborator

r? @matthewjasper

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 28, 2021
@cjgillot
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 28, 2021
@bors
Copy link
Contributor

bors commented Aug 28, 2021

⌛ Trying commit bc771728c56343d8fb09e4953354643a3473cea4 with merge ee52a1f5457264871e36cc1047d4bcbabd4f0a6a...

@bors
Copy link
Contributor

bors commented Aug 28, 2021

☀️ Try build successful - checks-actions
Build commit: ee52a1f5457264871e36cc1047d4bcbabd4f0a6a (ee52a1f5457264871e36cc1047d4bcbabd4f0a6a)

@rust-timer
Copy link
Collaborator

Queued ee52a1f5457264871e36cc1047d4bcbabd4f0a6a with parent 42a2a53, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (ee52a1f5457264871e36cc1047d4bcbabd4f0a6a): comparison url.

Summary: ERROR categorizing benchmark run!

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up.

@bors rollup=never
@rustbot label: +S-waiting-on-review -S-waiting-on-perf -perf-regression

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 28, 2021
@cjgillot
Copy link
Contributor Author

cjgillot commented Sep 1, 2021

r? @Aaron1011

@@ -519,6 +519,22 @@ impl<'hir> Map<'hir> {
}
}

/// Walks the contents of a crate. See also `Crate::visit_all_items`.
pub fn walk_crate(self, visitor: &mut impl Visitor<'hir>) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you rename this to something like walk_crate_without_crate_attrs, to make it clear that it doesn't walk everything in the crate?

@Aaron1011
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Sep 5, 2021

📌 Commit d119a13 has been approved by Aaron1011

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 5, 2021
@bors
Copy link
Contributor

bors commented Sep 5, 2021

⌛ Testing commit d119a13 with merge 7849e3e...

@bors
Copy link
Contributor

bors commented Sep 6, 2021

☀️ Test successful - checks-actions
Approved by: Aaron1011
Pushing 7849e3e to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 6, 2021
@bors bors merged commit 7849e3e into rust-lang:master Sep 6, 2021
@rustbot rustbot added this to the 1.57.0 milestone Sep 6, 2021
@cjgillot cjgillot deleted the no-walk-crate branch September 6, 2021 17:31
@pnkfelix
Copy link
Member

pnkfelix commented Sep 8, 2021

A performance run was done on this PR, but for some reason categorization failed.

The aforementioned performance run predicted that this would be a small win, at most.

However, during weekly performance triage, it was tagged as having mixed results on rustc instruction counts.

Tagging as perf-regression mostly as hint that maybe someone should go and figure out why there was a discrepancy between what was predicted during PR's run versus what actually happened when it landed on nightly.

@pnkfelix pnkfelix added the perf-regression Performance regression. label Sep 8, 2021
@Mark-Simulacrum
Copy link
Member

Trying to reproduce regressions locally in cachegrind led to a few improvements -- and the new significance algorithm puts them close to the significance threshold. So that seems consistent with the original results, and the new ones are probably closer to noise than actual meaningful changes. Marking as triaged; doesn't seem important to investigate further.

@Mark-Simulacrum Mark-Simulacrum added the perf-regression-triaged The performance regression has been triaged. label Oct 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants