Run various queries from other queries instead of explicitly in phases by oli-ob...
source link: https://github.com/rust-lang/rust/pull/108118
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Run various queries from other queries instead of explicitly in phases #108118
Conversation
Contributor
These are just legacy leftovers from when rustc didn't have a query system. While there are more cleanups of this sort that can be done here, I want to land them in smaller steps.
This phased order of query invocations was already a lie, as any query that looks at types (e.g. the wf checks run before) can invoke e.g. const eval which invokes borrowck, which invokes typeck, ...
Collaborator
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @wesleywiser (or someone else) soon. Please see the contribution instructions for more information. |
Contributor
Author
added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
labels
This comment has been minimized.
Collaborator
Some changes occurred in src/tools/clippy cc @rust-lang/clippy Some changes occurred in compiler/rustc_codegen_cranelift cc @bjorn3 Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label
@@ -529,8 +529,6 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> { | ||
tcx.hir().for_each_module(|module| tcx.ensure().check_mod_item_types(module)) |
||
}); |
||
tcx.sess.time("item_bodies_checking", || tcx.typeck_item_bodies(())); |
Contributor
What is going to ensure that typecheck errors for all functions are reported without this call?
Contributor
This also regresses the quality of the output of -Ztime-passes
.
Contributor
Author
as mentioned in the main post
This phased order of query invocations was already a lie, as any query that looks at types (e.g. the wf checks run before) can cause e.g. const eval which invokes borrowck, which invokes typeck, ...
we already didn't produce correct time tracking for it
Contributor
I think this is a good change, but maybe a safer intermediate step would be to "assert" that all the queries were run in the "passes" for now. This would ensure that we don't accidentally make a query more lazy, then skip something (accidentally). |
Contributor
Author
Hmm... we don't have the setup for doing that (also doing it at that phase won't work, as it may get run later). I'll see if I can add something to the query system for asserting that a query has been run |
Contributor
The latest upstream changes (presumably #101841) made this pull request unmergeable. Please resolve the merge conflicts. |
Contributor
Author
I looked into it, and we're already relying on the |
Contributor
Author
This comment has been minimized.
Contributor
I'm not sure I agree with the general direction. I'd rather suggest doing the opposite:
The fact that we run |
Contributor
Author
The problem with those useless dependencies is that e.g. const eval can run on code that doesn't satisfy various checks, leading to surprising bugs and workarounds in const eval. I agree that mir_built may be too early, but at the very least the mir_drops_elaborated_and_const_checked query should not finish before the various checks on the same def id are done. I guess my assumption was that at some point all we have to do is to either call the optimized_mir query for the main function and can compile from just the information from that, or call the analysis query to do a check build. If changing any of this negatively affects incremental, then we should not do it, but I don't see that being an issue in general with this scheme, just with the details of where to add edges. |
Collaborator
Finished benchmarking commit (41c8d3a): comparison URL. Overall result: regressions and improvements - 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. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @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)Results CyclesResults |
added perf-regression Performance regressions
and removed S-waiting-on-perf Status: Waiting on a perf run to be completed.
labels
Contributor
Author
Everything but |
Contributor
Author
about that, do we really add more dependencies with |
Contributor
Yes,
In those cases, we should rely on the One other symptom is the calls to
From the perf results, I have no proof that it does negatively affect incremental, so no serious grounds on which to block this PR. That's also why I frame it as a design question, more than an operational question. That said, we should merge that PR, as it does not lock anything in a way or the other. I'll have to make my case with an actual PR demonstrating the direction I have in mind . |
Contributor
Seeing #108705, I finally convinced myself that this PR is the right direction. This can help to avoid building MIR for broken code, which is that much potential ICEs and non-sensical diagnostics.
That's what |
Contributor
Author
Oh I meant something that asserts it instead of executing it. Though ensuring later will ICE due to stolen stuff, so it results in the same thing |
Contributor
The latest upstream changes (presumably #108089) made this pull request unmergeable. Please resolve the merge conflicts. |
This comment has been minimized.
Member
r=me when @cjgillot is happy |
Contributor
The latest upstream changes (presumably #96840) made this pull request unmergeable. Please resolve the merge conflicts. |
Contributor
@bors r+ |
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
Contributor
Test successful - checks-actions |
Collaborator
Finished benchmarking commit (3462f79): comparison URL. Overall result: regressions and 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)Results CyclesResults |
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Successfully merging this pull request may close these issues.
None yet
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK