-
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
resolve: Replace visibility table in resolver outputs with query feeding #118657
Conversation
r? @cjgillot (rustbot has picked a reviewer for you, use r? to override) |
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
resolve: Replace visibility table in resolver outputs with query feeding I suspect that in general this approach should work for queries that are 1) executed for most keys and 2) have results that are cheap to hash (do not have spans, in particular). Visibility query matches that description, so let's check.
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (526830d): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking 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. @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 675.495s -> 674.636s (-0.13%) |
66f2439
to
18d2bd2
Compare
@rustbot ready |
@cjgillot |
Yes. I'm not sure this is actually useful, but I wanted to avoid ICEing too eagerly.
We check that the fingerprints match. If the fingerprints do not match, we delay a bug. If the query is no-hash, we panic. |
compiler/rustc_privacy/src/lib.rs
Outdated
// Unique types created for closures participate in type privacy checking. | ||
// They have visibilities inherited from the module they are defined in. | ||
Node::Expr(hir::Expr { kind: hir::ExprKind::Closure { .. }, .. }) => { | ||
ty::Visibility::Restricted(tcx.parent_module_from_def_id(def_id).to_def_id()) |
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.
Is there a way to get rid of this completely?
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, but I wanted to do it in a separate PR because it may have a negative performance impact.
(Visibilities for item-like nodes are always queried anyway because they are encoded into metadata, but visibilities for closures are rarely queried so it makes sense to do it on demand.)
@bors r+ |
@@ -1133,8 +1131,6 @@ pub(super) fn crate_hash(tcx: TyCtxt<'_>, _: LocalCrate) -> Svh { | |||
} | |||
tcx.sess.opts.dep_tracking_hash(true).hash_stable(&mut hcx, &mut stable_hasher); | |||
tcx.stable_crate_id(LOCAL_CRATE).hash_stable(&mut hcx, &mut stable_hasher); | |||
// Hash visibility information since it does not appear in HIR. | |||
resolutions.visibilities.hash_stable(&mut hcx, &mut stable_hasher); |
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.
This is now hashed into tcx.hir_crate(()).opt_hir_hash
? Or how do we ensure that changing visibilities still affect the crate hash?
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 restored the previous visibility hashing logic in a slightly simplified form.
resolve: Replace visibility table in resolver outputs with query feeding Also feed missing visibilities for import stems and trait impl items, which were previously evaluated lazily. I suspect that in general this approach should work for queries that are 1) executed for most keys and 2) have results that are cheap to hash (do not have spans, in particular). Visibility query matches that description.
@bors r- |
☀️ Try build successful - checks-actions |
18d2bd2
to
b893623
Compare
#118657 (comment) |
This comment was marked as resolved.
This comment was marked as resolved.
r=me after rebase |
Also feed missing visibilities for import stems and trait impl items, which were previously evaluated lazily.
b893623
to
be321aa
Compare
@bors r=cjgillot |
☀️ Test successful - checks-actions |
Finished benchmarking commit (321b656): comparison URL. Overall result: ✅ improvements - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 670.368s -> 675.09s (0.70%) |
resolve: Eagerly feed closure visibilities Addresses rust-lang#118657 (comment)
resolve: Eagerly feed closure visibilities Also factor out all tcx-dependent operations performed for every created definition into `TyCtxt::create_def`. Addresses rust-lang#118657 (comment)
This PR seems to be causing an ICE in #119126 |
Also feed missing visibilities for import stems and trait impl items, which were previously evaluated lazily.
I suspect that in general this approach should work for queries that are 1) executed for most keys and 2) have results that are cheap to hash (do not have spans, in particular).
Visibility query matches that description.