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: Do not build expensive suggestions if they are not actually used #95255

Merged
merged 4 commits into from
Mar 25, 2022

Conversation

petrochenkov
Copy link
Contributor

And remove a bunch of (conditionally) unused parameters from path resolution functions.

This helps with performance issues in #94857, and should be helpful in general even without that.

@rustbot rustbot added 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 Mar 24, 2022
@rust-highfive
Copy link
Collaborator

r? @michaelwoerister

(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 Mar 24, 2022
@petrochenkov
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 Mar 24, 2022
@bors
Copy link
Contributor

bors commented Mar 24, 2022

⌛ Trying commit 7e878bb75e2a91159cb6a3f2e4cbabf09fdbb9b1 with merge 5ef703f1b77179a2f29e24ea3e1775a23765725c...

@petrochenkov petrochenkov removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 24, 2022
@@ -568,7 +568,7 @@ fn configure_cmake(
// We also do this if the user explicitly requested static libstdc++.
if builder.config.llvm_static_stdcpp {
if !target.contains("msvc") && !target.contains("netbsd") {
if target.contains("apple") {
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like unintended change

Copy link
Contributor Author

@petrochenkov petrochenkov Mar 24, 2022

Choose a reason for hiding this comment

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

This is a drive-by fix for #94832 (comment) without which Rust doesn't build on my machine.

UPD: submitted as a separate PR in #95266.

@bors
Copy link
Contributor

bors commented Mar 24, 2022

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

@rust-timer
Copy link
Collaborator

Queued 5ef703f1b77179a2f29e24ea3e1775a23765725c with parent 9f4dc0b, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (5ef703f1b77179a2f29e24ea3e1775a23765725c): comparison url.

Summary: This benchmark run shows 35 relevant improvements 🎉 to instruction counts.

  • Arithmetic mean of relevant improvements: -0.6%
  • Largest improvement in instruction counts: -2.2% on full builds of projection-caching doc

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

Benchmarking 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 led to changes in compiler perf.

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

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Mar 24, 2022
#[derive(Copy, Clone, PartialEq, Debug)]
enum CrateLint {
#[derive(Copy, Clone, Debug)]
enum RecordUsed {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe this enum should have some different name.
It should be short because it's used often.

There are two path resolution modes:

  • Speculative mode - we only return the result, but do not report errors or lints, and do not do recovery
  • Non-speculative mode - we report errors, do recovery when possible, also report lints, and mark path targets as used (the record_used naming comes from this). That's why need some extra data like a node id for linting or a span in this mode.

Maybe call it enum Finalize?
It's two letters shorter, not as specific as the old "record used" naming, and we use "finalize" elsewhere in resolve for similar functionality, like fn finalize_(imports,macro_resolutions).

Copy link
Member

Choose a reason for hiding this comment

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

Maybe something like

enum Mode {
  Speculative,
  Finalize
}

?

enum Finalize looks OK to me though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've renamed everything to Finalize/finalize, but kept it a single flat enum (with Finalize::No variant), otherwise it becomes too annoying to both construct and unwrap it.

@michaelwoerister
Copy link
Member

Let me know when this is ready for review 👍

@petrochenkov
Copy link
Contributor Author

@michaelwoerister
It is ready.

@michaelwoerister
Copy link
Member

This looks like some great cleanup work. Lots of duplicate error messages being removed too.
I don't really know the code involved here -- but since this still passes all tests and the code diff looks reasonable to me, you can r=me. If you'd like to have more in-depth feedback, it's better to ask for a review from someone else.

@petrochenkov petrochenkov 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 Mar 24, 2022
…used

Also remove a redundant parameter from `fn resolve_path(_with_ribs)`, `crate_lint: CrateLint` is a more detailed version of `record_used: bool` with `CrateLint::No` meaning `false` and anything else meaning `true`.
Do not construct or pass unused data
And `crate_lint`/`record_used` to `finalize`
@petrochenkov
Copy link
Contributor Author

If you'd like to have more in-depth feedback, it's better to ask for a review from someone else.

No, nothing too deep happens here, I mostly wanted some second opinion on naming.
@rustbot ready

@rustbot rustbot 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 Mar 24, 2022
@michaelwoerister
Copy link
Member

OK, looks good to me.
@bors r+

@bors
Copy link
Contributor

bors commented Mar 25, 2022

📌 Commit 1ad64a2 has been approved by michaelwoerister

@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 Mar 25, 2022
@bors
Copy link
Contributor

bors commented Mar 25, 2022

⌛ Testing commit 1ad64a2 with merge 903427b...

@bors
Copy link
Contributor

bors commented Mar 25, 2022

☀️ Test successful - checks-actions
Approved by: michaelwoerister
Pushing 903427b to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 25, 2022
@bors bors merged commit 903427b into rust-lang:master Mar 25, 2022
@rustbot rustbot added this to the 1.61.0 milestone Mar 25, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (903427b): comparison url.

Summary: This benchmark run shows 33 relevant improvements 🎉 to instruction counts.

  • Arithmetic mean of relevant improvements: -0.6%
  • Largest improvement in instruction counts: -2.1% on full builds of projection-caching doc

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

@rustbot label: -perf-regression

bors added a commit to rust-lang-ci/rust that referenced this pull request May 1, 2022
resolve: Cleanup path resolution finalization

Some cleanup after rust-lang#95255 and rust-lang#95405.
r? `@cjgillot`
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. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants