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

resolve: Scale back unloading of speculatively loaded crates #121167

Merged
merged 1 commit into from
Feb 20, 2024

Conversation

petrochenkov
Copy link
Contributor

Fixes #120830 and fixes #120909 while still unblocking #117772.

I cannot reproduce https://github.com/parasyte/crash-rustc as an UI test for some reason, but I tested all the cases linked above manually.

@rustbot
Copy link
Collaborator

rustbot commented Feb 15, 2024

r? @wesleywiser

rustbot has assigned @wesleywiser.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@petrochenkov
Copy link
Contributor Author

Why #120830 had issues:

Both issues are potentially fixable.
Uses of SourceFile::cnum can be updated to check for the presence of CrateMetadata (there are just 2 or 3 of them), and the encoding/decoding logic can be rewritten.
I just won't have time to do all this in the next couple of weeks.

There may be other issues though.
Any attempts to re-land the more radical version of crate unloading, resetting crate metadatas to None, will need to go through crater.

query used_crates(_: ()) -> &'tcx [CrateNum] {
eval_always
desc { "fetching `CrateNum`s for all crates loaded non-speculatively" }
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we directly change the implementation of crates?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In some cases the new version should not be used (e.g. in metadata encoding due to #121167 (comment)), but I didn't audit in which exactly and switched only one case that is necessary for #117772.

@@ -1872,6 +1872,13 @@ rustc_queries! {
eval_always
desc { "fetching all foreign CrateNum instances" }
}
// Crates that are loaded non-speculatively (not for diagnostics or doc links).
// FIXME: This is currently only used for collecting lang items, but should be used instead of
// `crates` in most other cases too.
Copy link
Member

Choose a reason for hiding this comment

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

Can we describe what situations would require using crates instead or is there not a common theme?

Copy link
Contributor Author

@petrochenkov petrochenkov Feb 18, 2024

Choose a reason for hiding this comment

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

Metadata encoding at least, if the second item in #121167 (comment) is not fixed.
If metadata includes unused crates, then SVH and binary depinfo should probably include them either.

Any diagnostic logic, like trimmed_def_paths may include them as well, because why not.

Lang item collection, impl collection, linking certainly shouldn't include speculatively loaded crates.

@bors

This comment was marked as resolved.

@wesleywiser
Copy link
Member

Thanks for the quick fix @petrochenkov!

@bors r+

@bors
Copy link
Contributor

bors commented Feb 20, 2024

📌 Commit 24cffbf has been approved by wesleywiser

It is now in the queue for this repository.

@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 Feb 20, 2024
Noratrieb added a commit to Noratrieb/rust that referenced this pull request Feb 20, 2024
resolve: Scale back unloading of speculatively loaded crates

Fixes rust-lang#120830 and fixes rust-lang#120909 while still unblocking rust-lang#117772.

I cannot reproduce https://github.com/parasyte/crash-rustc as an UI test for some reason, but I tested all the cases linked above manually.
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 20, 2024
Rollup of 8 pull requests

Successful merges:

 - rust-lang#121167 (resolve: Scale back unloading of speculatively loaded crates)
 - rust-lang#121196 (Always inline check in `assert_unsafe_precondition` with cfg(debug_assertions))
 - rust-lang#121206 (Top level error handling)
 - rust-lang#121223 (intrinsics::simd: add missing functions)
 - rust-lang#121241 (Implement `NonZero` traits generically.)
 - rust-lang#121242 (Generate `getelementptr` instead of `inttoptr` for `ptr::invalid`)
 - rust-lang#121278 (Remove the "codegen" profile from bootstrap)
 - rust-lang#121286 (Rename `ConstPropLint` to `KnownPanicsLint`)

r? `@ghost`
`@rustbot` modify labels: rollup
Noratrieb added a commit to Noratrieb/rust that referenced this pull request Feb 20, 2024
resolve: Scale back unloading of speculatively loaded crates

Fixes rust-lang#120830 and fixes rust-lang#120909 while still unblocking rust-lang#117772.

I cannot reproduce https://github.com/parasyte/crash-rustc as an UI test for some reason, but I tested all the cases linked above manually.
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 20, 2024
Rollup of 8 pull requests

Successful merges:

 - rust-lang#121167 (resolve: Scale back unloading of speculatively loaded crates)
 - rust-lang#121196 (Always inline check in `assert_unsafe_precondition` with cfg(debug_assertions))
 - rust-lang#121241 (Implement `NonZero` traits generically.)
 - rust-lang#121278 (Remove the "codegen" profile from bootstrap)
 - rust-lang#121286 (Rename `ConstPropLint` to `KnownPanicsLint`)
 - rust-lang#121291 (target: Revert default to the medium code model on LoongArch targets)
 - rust-lang#121302 (Remove `RefMutL` hack in `proc_macro::bridge`)
 - rust-lang#121318 (Trigger `unsafe_code` lint on invocations of `global_asm`)

Failed merges:

 - rust-lang#121206 (Top level error handling)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 073d298 into rust-lang:master Feb 20, 2024
11 checks passed
@rustbot rustbot added this to the 1.78.0 milestone Feb 20, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 20, 2024
Rollup merge of rust-lang#121167 - petrochenkov:unload2, r=wesleywiser

resolve: Scale back unloading of speculatively loaded crates

Fixes rust-lang#120830 and fixes rust-lang#120909 while still unblocking rust-lang#117772.

I cannot reproduce https://github.com/parasyte/crash-rustc as an UI test for some reason, but I tested all the cases linked above manually.
bors added a commit to rust-lang-ci/rust that referenced this pull request May 22, 2024
rustc: Use `tcx.used_crates(())` more

And explain when it should be used.

Addresses comments from rust-lang#121167.
bors added a commit to rust-lang-ci/rust that referenced this pull request May 22, 2024
rustc: Use `tcx.used_crates(())` more

And explain when it should be used.

Addresses comments from rust-lang#121167.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request May 23, 2024
rustc: Use `tcx.used_crates(())` more

And explain when it should be used.

Addresses comments from rust-lang#121167.
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request May 23, 2024
Rollup merge of rust-lang#124976 - petrochenkov:usedcrates, r=oli-obk

rustc: Use `tcx.used_crates(())` more

And explain when it should be used.

Addresses comments from rust-lang#121167.
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request May 24, 2024
rustc: Use `tcx.used_crates(())` more

And explain when it should be used.

Addresses comments from rust-lang/rust#121167.
flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request May 24, 2024
rustc: Use `tcx.used_crates(())` more

And explain when it should be used.

Addresses comments from rust-lang/rust#121167.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
5 participants