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

Include (potentially remapped) working dir in crate hash #87990

Merged
merged 4 commits into from
Aug 17, 2021

Conversation

Aaron1011
Copy link
Member

@Aaron1011 Aaron1011 commented Aug 12, 2021

Fixes #85019

A SourceFile created during compilation may have a relative
path (e.g. if rustc itself is invoked with a relative path).
When we write out crate metadata, we convert all relative paths
to absolute paths using the current working directory.

However, the working directory is not included in the crate hash.
This means that the crate metadata can change while the crate
hash remains the same. Among other problems, this can cause a
fingerprint mismatch ICE, since incremental compilation uses
the crate metadata hash to determine if a foreign query is green.

This commit moves the field holding the working directory from
Session to Options, including it as part of the crate hash.

cc @ohsayan

@rust-highfive
Copy link
Collaborator

r? @cjgillot

(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 Aug 12, 2021
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@Aaron1011 Aaron1011 force-pushed the moved-src-dir branch 2 times, most recently from ecd4d58 to 8e82f87 Compare August 13, 2021 00:40
@Aaron1011
Copy link
Member 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 Aug 13, 2021
@bors
Copy link
Contributor

bors commented Aug 13, 2021

⌛ Trying commit 8e82f8779b94c4f331f905d0ad1ee2ced86ddd42 with merge 00b86ce65e27b89f376907d04ba69c76ee8fa88f...

@bors
Copy link
Contributor

bors commented Aug 13, 2021

☀️ Try build successful - checks-actions
Build commit: 00b86ce65e27b89f376907d04ba69c76ee8fa88f (00b86ce65e27b89f376907d04ba69c76ee8fa88f)

@rust-timer
Copy link
Collaborator

Queued 00b86ce65e27b89f376907d04ba69c76ee8fa88f with parent 0fa3190, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (00b86ce65e27b89f376907d04ba69c76ee8fa88f): comparison url.

Summary: This change led to significant regressions 😿 in compiler performance.

  • Small regression in instruction counts (up to 0.3% on incr-unchanged builds of helloworld)

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.

Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

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

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Aug 13, 2021
@cjgillot
Copy link
Contributor

r=me with a comment explaining why the new implementation is safe.

@Aaron1011
Copy link
Member Author

The perf regressions are very small, and this is a correctness fix.

@rustbot label: +perf-regression-triaged

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Aug 15, 2021
@Aaron1011
Copy link
Member Author

@bors r=cjgillot

@bors
Copy link
Contributor

bors commented Aug 15, 2021

📌 Commit 47daf829b1a0d2d499745a34cf4b1969929e5f7f 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 Aug 15, 2021
@@ -203,6 +204,9 @@ top_level_options!(
json_unused_externs: bool [UNTRACKED],

pretty: Option<PpMode> [UNTRACKED],

/// The (potentially remapped) working directory
working_dir: RealFileName [TRACKED],
Copy link
Member

Choose a reason for hiding this comment

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

This will result in a different hash for /wd/foo.rs vs /baz/foo.rs with /baz remapped to /wd despite the filename after any remapping being equal.

Copy link
Member Author

@Aaron1011 Aaron1011 Aug 15, 2021

Choose a reason for hiding this comment

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

I don't think so - this field is initialized using the remapped working directory.

Copy link
Member

Choose a reason for hiding this comment

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

RealFileName is an enum defined as

#[derive(HashStable_Generic)]
enum RealFileName {
    LocalPath(PathBuf),
    Remapped {
        local_path: Option<PathBuf>,
        virtual_name: PathBuf,
    },
}

while the Hash implementation only looks at the remapped path, the HashStable implementation is derived and looks at which enum variant it is and in case of a remapped path also at the local path before remapping. The dep tracking hash is calculated using HashStable and not Hash, so this will depend if the path is remapped or not and more importantly the local path before remapping, which is even worse that I thought as it breaks reproducible builds.

Copy link
Member Author

Choose a reason for hiding this comment

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

The dep tracking hash is calculated using HashStable and not Hash

That's incorrect - I'm using impl_dep_tracking_hash_via_hash for RealFileName: https://github.com/Aaron1011/rust/blob/47daf829b1a0d2d499745a34cf4b1969929e5f7f/compiler/rustc_session/src/config.rs#L2513

It looks like the HashStable implementations for FileName and RealFileName are unused, and can be removed. Having Hash, HashStable,andDepTrackingHash` all implemented for a single type is pretty confusing - I wonder if there's any kind of compile-time check we can do to prevent that.

@bors
Copy link
Contributor

bors commented Aug 15, 2021

⌛ Testing commit 47daf829b1a0d2d499745a34cf4b1969929e5f7f with merge c6dcf24421076fedab2ade1ed496090bba3b2213...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Aug 15, 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 Aug 15, 2021
@Aaron1011
Copy link
Member Author

@bors r=cjgillot

@bors
Copy link
Contributor

bors commented Aug 15, 2021

📌 Commit 1ac7881 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 Aug 15, 2021
@bors
Copy link
Contributor

bors commented Aug 16, 2021

⌛ Testing commit 1ac7881 with merge bb758a338d556941407cde190135e1cdd948544a...

@bors
Copy link
Contributor

bors commented Aug 16, 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 Aug 16, 2021
@rust-log-analyzer
Copy link
Collaborator

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@Aaron1011
Copy link
Member Author

@bors retry

@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 Aug 16, 2021
@bors
Copy link
Contributor

bors commented Aug 17, 2021

⌛ Testing commit 1ac7881 with merge a183141...

@bors
Copy link
Contributor

bors commented Aug 17, 2021

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

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Aug 17, 2021
@bors bors merged commit a183141 into rust-lang:master Aug 17, 2021
@rustbot rustbot added this to the 1.56.0 milestone Aug 17, 2021
@rust-highfive
Copy link
Collaborator

📣 Toolstate changed by #87990!

Tested on commit a183141.
Direct link to PR: #87990

💔 rls on windows: test-pass → build-fail (cc @Xanewok).
💔 rls on linux: test-pass → build-fail (cc @Xanewok).

rust-highfive added a commit to rust-lang-nursery/rust-toolstate that referenced this pull request Aug 17, 2021
Tested on commit rust-lang/rust@a183141.
Direct link to PR: <rust-lang/rust#87990>

💔 rls on windows: test-pass → build-fail (cc @Xanewok).
💔 rls on linux: test-pass → build-fail (cc @Xanewok).
Mark-Simulacrum added a commit to rust-lang/rls that referenced this pull request Sep 7, 2021
calebcartwright pushed a commit to calebcartwright/rls that referenced this pull request Nov 5, 2021
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. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. 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.

unstable fingerprints for item_children - ICE on Rust 1.52.0 stable
8 participants