Skip to content

Conversation

Mark-Simulacrum
Copy link
Member

@Mark-Simulacrum Mark-Simulacrum commented Sep 28, 2021

This PR replaces can_reconstruct_query_key with fingerprint_style, which returns the style of the fingerprint for that query. This allows us to avoid trying to extract a DefId (or equivalent) from keys which are reconstructible because they're () but not as DefIds.

This is done with the goal of fixing -Zdump-dep-graph, which seems to have broken a while ago (I didn't try to bisect). Currently even on a fn main() {} file it'll ICE (you need to also pass -Zquery-dep-graph for it to work at all), and this patch indirectly fixes the cause of that ICE. This also adds a test for it continuing to work.

@rust-highfive
Copy link
Contributor

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 Sep 28, 2021
@Mark-Simulacrum
Copy link
Member Author

cc @rust-lang/wg-incr-comp -- I'm not sure if folks recall the intent of has_params, which might be helpful to determine if this is the "right" thing to do.

@cjgillot
Copy link
Contributor

IIUC, the crash happens when trying to debug-print a DepNode whch parameter () by mistakenly trying to extract a DefId from a Fingerprint which is not a proper DefPathHash. The bug is therefore in rustc_middle::dep_graph::dep_node::DepNodeExt::extract_def_id which tests can_reconstruct_query_key() to know whether the query key is a CrateNum/LocalDefId/DefId. I think this PR hides the problem rather than solving it. The correct fix would be to create a separate has_def_path_hash field in DepKindStruct which tests whether the query key is any of the three, and equivalently if a DefId can be extracted from the fingerprint.

@Mark-Simulacrum
Copy link
Member Author

Hm, that seems like a good thing to tackle, I agree. I think this PR is still desirable (or we should just remove has_params), since it seems like the meaning of that is not too clear right now.

I'll have to dig into the 2 manually declared queries with has_params: false, and see if that's significant for them...

@cjgillot cjgillot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 29, 2021
@Mark-Simulacrum Mark-Simulacrum changed the title Fix -Zdump-dep-graph Refactor fingerprint reconstruction Oct 2, 2021
@Mark-Simulacrum Mark-Simulacrum force-pushed the no-args-queries branch 2 times, most recently from 175631d to 3d73c4d Compare October 2, 2021 16:31
@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 2, 2021
@rust-log-analyzer

This comment has been minimized.

@Mark-Simulacrum Mark-Simulacrum force-pushed the no-args-queries branch 2 times, most recently from 9173a20 to 63aaf88 Compare October 2, 2021 16:44
@Mark-Simulacrum
Copy link
Member Author

Alright, replaced pretty much the whole PR with different patch -- and extracted #89466 for the base macro changes which are not actually needed for this PR now.

I looked into fully removing has_params but didn't end up making that change. The only uses left are the debug assert in DepKind::new_no_params and the debug_node method. The latter could be removed with no loss, I believe -- just a difference in how nodes look (printed as foo today, foo() with that condition dropped). Since has_params is true currently for all but Null and TraitSelect DepKinds (neither of which is a proper query), it's probably the case that this could be refactored. But seems like future work.

match kind.fingerprint_style() {
FingerprintStyle::Opaque => Err(()),
FingerprintStyle::Unit => {
if !kind.has_params {
Copy link
Contributor

Choose a reason for hiding this comment

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

FingerprintStyle::Unit should now be equivalent to has_params == false, isn't it? We should be able to get rid of has_params.

Copy link
Member Author

@Mark-Simulacrum Mark-Simulacrum Oct 2, 2021

Choose a reason for hiding this comment

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

Not currently. A query with () key currently "has_params"; the only two things to not have params are Null and TraitSelect which are not generated through the normal macro infrastructure. I dropped the "fix" for that from this branch for now, though I can re-add it, it's not big (b2b53bb9a4f2f5e1f96f8f01ad7b378f5eb1b4d1).

@cjgillot
Copy link
Contributor

cjgillot commented Oct 2, 2021

@bors r+

@bors
Copy link
Collaborator

bors commented Oct 2, 2021

📌 Commit 63aaf88 has been approved by cjgillot

@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 Oct 2, 2021
Manishearth added a commit to Manishearth/rust that referenced this pull request Oct 3, 2021
…cjgillot

Refactor fingerprint reconstruction

This PR replaces can_reconstruct_query_key with fingerprint_style, which returns the style of the fingerprint for that query. This allows us to avoid trying to extract a DefId (or equivalent) from keys which *are* reconstructible because they're () but not as DefIds.

This is done with the goal of fixing -Zdump-dep-graph, which seems to have broken a while ago (I didn't try to bisect). Currently even on a `fn main() {}` file it'll ICE (you need to also pass -Zquery-dep-graph for it to work at all), and this patch indirectly fixes the cause of that ICE. This also adds a test for it continuing to work.
@bors
Copy link
Collaborator

bors commented Oct 5, 2021

☔ The latest upstream changes (presumably #89266) made this pull request unmergeable. Please resolve the merge conflicts.

Keys can be reconstructed from fingerprints that are not DefPathHash, but then
we cannot extract a DefId from them.
@Mark-Simulacrum
Copy link
Member Author

@bors r=cjgillot rollup=iffy

@bors
Copy link
Collaborator

bors commented Oct 7, 2021

📌 Commit 85c4fd81799de01e8eb3a84f96a13baafc8de407 has been approved by cjgillot

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 7, 2021
@bors
Copy link
Collaborator

bors commented Oct 9, 2021

⌛ Testing commit 85c4fd81799de01e8eb3a84f96a13baafc8de407 with merge 8f2565b630f71928671276797f4659fcc679d795...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Oct 9, 2021

💔 Test failed - checks-actions

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

@bors r=cjgillot rollup=iffy

@bors
Copy link
Collaborator

bors commented Oct 9, 2021

📌 Commit 415a9a2 has been approved by cjgillot

@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 Oct 9, 2021
@bors
Copy link
Collaborator

bors commented Oct 9, 2021

⌛ Testing commit 415a9a2 with merge 15491d7...

@bors
Copy link
Collaborator

bors commented Oct 9, 2021

☀️ Test successful - checks-actions
Approved by: cjgillot
Pushing 15491d7 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Oct 9, 2021
@bors bors merged commit 15491d7 into rust-lang:master Oct 9, 2021
@rustbot rustbot added this to the 1.57.0 milestone Oct 9, 2021
@Mark-Simulacrum Mark-Simulacrum deleted the no-args-queries branch October 9, 2021 17:02
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (15491d7): comparison url.

Summary: This benchmark run did not return any relevant changes.

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

@rustbot label: -perf-regression

tgnottingham added a commit to tgnottingham/rust that referenced this pull request Oct 18, 2021
Debug logging during incremental compilation had been broken for some
time, until rust-lang#89343 fixed it (among other things). Add a test so this is
less likely to break without being noticed. This test is nearly a copy
of the `src/test/ui/rustc-rust-log.rs` test, but tests debug logging in
the incremental compliation code paths.
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Oct 21, 2021
…t, r=Mark-Simulacrum

Add test for debug logging during incremental compilation

Debug logging during incremental compilation had been broken for some
time, until rust-lang#89343 fixed it (among other things). Add a test so this is
less likely to break without being noticed. This test is nearly a copy
of the `src/test/ui/rustc-rust-log.rs` test, but tests debug logging in
the incremental compliation code paths.
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Oct 21, 2021
…t, r=Mark-Simulacrum

Add test for debug logging during incremental compilation

Debug logging during incremental compilation had been broken for some
time, until rust-lang#89343 fixed it (among other things). Add a test so this is
less likely to break without being noticed. This test is nearly a copy
of the `src/test/ui/rustc-rust-log.rs` test, but tests debug logging in
the incremental compliation code paths.
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. 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