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 source file hash in crate_hash. #94301

Closed
wants to merge 2 commits into from

Conversation

cjgillot
Copy link
Contributor

The current crate hash contains the hash of HIR nodes.
However, HIR does not necessarily contain all the information which transits in the query system (for instance stored in ResolverOutputs).
To avoid issues, this PR switches to using the hash of the source files instead.

r? @Aaron1011

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Feb 23, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 23, 2022
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@cjgillot
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 Feb 23, 2022
@bors
Copy link
Contributor

bors commented Feb 23, 2022

⌛ Trying commit ef7950b22e1b204644453ecf3cafb0cc021785b2 with merge 04ddb49743e80584583be1b304307deff2cfba38...

@eddyb
Copy link
Member

eddyb commented Feb 23, 2022

I wonder if there is some risk here of missing something that can cause HIR to differ.

Hard to check, would probably have to hack up incremental to store both hashes and assert that if the hash from this PR is unchanged, the older HIR-based hash is also unchanged (but that doesn't protect from anything weirder, and it's not like rustc has "phone home" functionality for freak accidents, either).

@bors
Copy link
Contributor

bors commented Feb 23, 2022

☀️ Try build successful - checks-actions
Build commit: 04ddb49743e80584583be1b304307deff2cfba38 (04ddb49743e80584583be1b304307deff2cfba38)

@rust-timer
Copy link
Collaborator

Queued 04ddb49743e80584583be1b304307deff2cfba38 with parent 532d3cd, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (04ddb49743e80584583be1b304307deff2cfba38): comparison url.

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

  • Average relevant improvement: -0.8%
  • Largest improvement in instruction counts: -0.8% on incr-unchanged builds of externs opt

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 removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 24, 2022
@petrochenkov
Copy link
Contributor

missing something that can cause HIR to differ

Something like environment variables, for example?
env!("FOO") always has the same source, but its result in HIR may change with time.

Also proc macros can produce random data out of thin air, I guess.

@@ -1140,20 +1147,6 @@ pub(super) fn crate_hash(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Svh {
Svh::new(crate_hash.to_smaller_hash())
}

fn upstream_crates(tcx: TyCtxt<'_>) -> Vec<(StableCrateId, Svh)> {
Copy link
Member

Choose a reason for hiding this comment

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

Is there any particular reason for inlining this method? I don't have a strong preference about where this code should be, but it's currently adding unrelated changes to the diff.

@bors
Copy link
Contributor

bors commented Feb 25, 2022

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

@Aaron1011 Aaron1011 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 2, 2022
@cjgillot cjgillot closed this Jul 30, 2022
@cjgillot cjgillot deleted the source-crate-hash branch August 7, 2022 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants