-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Avoid unnecessary hashing #108794
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
Avoid unnecessary hashing #108794
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -224,6 +224,13 @@ pub struct PerfStats { | |
pub normalize_projection_ty: AtomicUsize, | ||
} | ||
|
||
#[derive(PartialEq, Eq, PartialOrd, Ord)] | ||
pub enum MetadataKind { | ||
None, | ||
Uncompressed, | ||
Compressed, | ||
} | ||
|
||
impl Session { | ||
pub fn miri_unleashed_feature(&self, span: Span, feature_gate: Option<Symbol>) { | ||
self.miri_unleashed_features.lock().push((span, feature_gate)); | ||
|
@@ -287,6 +294,38 @@ impl Session { | |
self.crate_types.get().unwrap().as_slice() | ||
} | ||
|
||
pub fn needs_crate_hash(&self) -> bool { | ||
// Why is the crate hash needed for these configurations? | ||
// - debug_assertions: for the "fingerprint the result" check in | ||
// `rustc_query_system::query::plumbing::execute_job`. | ||
// - incremental: for query lookups. | ||
// - needs_metadata: for putting into crate metadata. | ||
// - instrument_coverage: for putting into coverage data (see | ||
// `hash_mir_source`). | ||
cfg!(debug_assertions) | ||
|| self.opts.incremental.is_some() | ||
|| self.needs_metadata() | ||
|| self.instrument_coverage() | ||
} | ||
|
||
pub fn metadata_kind(&self) -> MetadataKind { | ||
self.crate_types() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Although almost all current regressions are incremental so this isn't a factor, would it not be worth caching this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not showing up at all in profiles, so it's not worth optimizing. |
||
.iter() | ||
.map(|ty| match *ty { | ||
CrateType::Executable | CrateType::Staticlib | CrateType::Cdylib => { | ||
MetadataKind::None | ||
} | ||
CrateType::Rlib => MetadataKind::Uncompressed, | ||
CrateType::Dylib | CrateType::ProcMacro => MetadataKind::Compressed, | ||
}) | ||
.max() | ||
.unwrap_or(MetadataKind::None) | ||
} | ||
|
||
pub fn needs_metadata(&self) -> bool { | ||
self.metadata_kind() != MetadataKind::None | ||
} | ||
|
||
pub fn init_crate_types(&self, crate_types: Vec<CrateType>) { | ||
self.crate_types.set(crate_types).expect("`crate_types` was initialized twice") | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.