-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Merge CrateDisambiguator into StableCrateId #85804
Conversation
(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.
2eaeaff
to
2a2d4af
Compare
This comment has been minimized.
This comment has been minimized.
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 195e4a24be951480d9d27bd44a0f30771e374ae3 with merge 621a481ceedc7341caa1c2cdb9f083e0a2d47de4... |
This comment has been minimized.
This comment has been minimized.
☀️ Try build successful - checks-actions |
Queued 621a481ceedc7341caa1c2cdb9f083e0a2d47de4 with parent f77b1a5, future comparison URL. |
Finished benchmarking try commit (621a481ceedc7341caa1c2cdb9f083e0a2d47de4): comparison url. Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up. @bors rollup=never |
Overall this seems to be a slight perf improvement. I would guess that the regressions are caused by the fact that the |
195e4a2
to
d7408a7
Compare
This comment has been minimized.
This comment has been minimized.
d7408a7
to
329187f
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
56ac1c2
to
576488e
Compare
☔ The latest upstream changes (presumably #85698) made this pull request unmergeable. Please resolve the merge conflicts. |
☀️ Test successful - checks-actions |
Would you mind updating the rustc-dev-guide to accommodate this change? https://rustc-dev-guide.rust-lang.org/backend/libs-and-metadata.html#crate-disambiguator Also, this seems to drop the hash size from 128 bits to 64 bits, but I don't see any discussion here if that might cause any problems? |
Sure Edit: rust-lang/rustc-dev-guide#1135
It was already impossible to have two crates with different disambiguators but identical |
Thanks I appreciate it! |
@bjorn3 It seems like this was a regression on landing - https://perf.rust-lang.org/compare.html?start=2023cc3aa1ea98530f3124ed07713e6f95fd26ab&end=59579907ab52ad2369735622185a26f158bf0f0f&stat=instructions%3Au . This seems held up by further perf runs over the course of the week, too, so likely not spurious. I think we should measure a revert PR, at the very least; would you be up for posting that? |
Strange. The previous perf run showed that it was an improvement.
Done: #85891 |
pub struct StableCrateId(u64); | ||
|
||
impl StableCrateId { | ||
pub fn to_u64(self) -> u64 { |
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 forgot to mark this as #[inline]
. Maybe that is responsible for the perf regression?
pub fn generate_proc_macro_decls_symbol(&self, disambiguator: CrateDisambiguator) -> String { | ||
format!("__rustc_proc_macro_decls_{}__", disambiguator.to_fingerprint().to_hex()) | ||
pub fn generate_proc_macro_decls_symbol(&self, stable_crate_id: StableCrateId) -> String { | ||
format!("__rustc_proc_macro_decls_{:08x}__", stable_crate_id.to_u64()) |
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.
Using {:08x}
instead of {:x}
like to_hex()
seems to have used may also be part of the problem.
let crate_name = tcx.original_crate_name(cnum).to_string(); | ||
let crate_disambiguator = tcx.crate_disambiguator(cnum); | ||
((crate_name, crate_disambiguator), cnum) | ||
let stable_crate_id = tcx.def_path_hash(cnum.as_def_id()).stable_crate_id(); |
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.
Avoiding the def_path_hash
call here in favor of directly looking up the StableCrateId
by CrateNum
from the CStore
may also help.
…or, r=Mark-Simulacrum Revert "Merge CrateDisambiguator into StableCrateId" This reverts rust-lang#85804
…mbiguator, r=michaelwoerister Reland "Merge CrateDisambiguator into StableCrateId" Reverts rust-lang#85891 as this revert of rust-lang#85804 made perf even worse. r? `@Mark-Simulacrum`
This simplifies the code and potentially improves performance by reducing the amount of hashed data.
Fixes #85795