-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Conversation
r? @cjgillot (rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
ecd4d58
to
8e82f87
Compare
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 8e82f8779b94c4f331f905d0ad1ee2ced86ddd42 with merge 00b86ce65e27b89f376907d04ba69c76ee8fa88f... |
☀️ Try build successful - checks-actions |
Queued 00b86ce65e27b89f376907d04ba69c76ee8fa88f with parent 0fa3190, future comparison URL. |
Finished benchmarking try commit (00b86ce65e27b89f376907d04ba69c76ee8fa88f): comparison url. Summary: This change led to significant regressions 😿 in compiler performance.
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 @bors rollup=never |
r=me with a comment explaining why the new implementation is safe. |
8e82f87
to
47daf82
Compare
The perf regressions are very small, and this is a correctness fix. @rustbot label: +perf-regression-triaged |
@bors r=cjgillot |
📌 Commit 47daf829b1a0d2d499745a34cf4b1969929e5f7f has been approved by |
@@ -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], |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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,and
DepTrackingHash` 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.
⌛ Testing commit 47daf829b1a0d2d499745a34cf4b1969929e5f7f with merge c6dcf24421076fedab2ade1ed496090bba3b2213... |
This comment has been minimized.
This comment has been minimized.
💔 Test failed - checks-actions |
@bors r=cjgillot |
📌 Commit 1ac7881 has been approved by |
⌛ Testing commit 1ac7881 with merge bb758a338d556941407cde190135e1cdd948544a... |
💔 Test failed - checks-actions |
@bors retry |
☀️ Test successful - checks-actions |
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).
Fixes #85019
A
SourceFile
created during compilation may have a relativepath (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
toOptions
, including it as part of the crate hash.cc @ohsayan