diff options
| author | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2025-03-18 00:05:45 +0100 |
|---|---|---|
| committer | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2025-03-19 20:12:37 +0100 |
| commit | e70cafec4e632aa0b14c5e81d1d64c5d944021cc (patch) | |
| tree | 5910b4b1f38a0daaa5669e7b655cc088cb46080d | |
| parent | 5a21f890e9b6aad452638a45e0ebce025da7334f (diff) | |
| download | rust-e70cafec4e632aa0b14c5e81d1d64c5d944021cc.tar.gz rust-e70cafec4e632aa0b14c5e81d1d64c5d944021cc.zip | |
Outline some cold code and turn on hash collision detection with debug_assertions
| -rw-r--r-- | compiler/rustc_query_system/src/dep_graph/graph.rs | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/compiler/rustc_query_system/src/dep_graph/graph.rs b/compiler/rustc_query_system/src/dep_graph/graph.rs index 22926c0d146..89372bd24d2 100644 --- a/compiler/rustc_query_system/src/dep_graph/graph.rs +++ b/compiler/rustc_query_system/src/dep_graph/graph.rs @@ -8,6 +8,7 @@ use std::sync::atomic::{AtomicU32, Ordering}; use rustc_data_structures::fingerprint::{Fingerprint, PackedFingerprint}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; +use rustc_data_structures::outline; use rustc_data_structures::profiling::QueryInvocationId; use rustc_data_structures::sharded::{self, Sharded}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; @@ -675,8 +676,10 @@ impl<D: Deps> DepGraphData<D> { } else if let Some(nodes_newly_allocated_in_current_session) = &self.current.nodes_newly_allocated_in_current_session { - let seen = nodes_newly_allocated_in_current_session.lock().contains(dep_node); - assert!(!seen, "{}", msg()); + outline(|| { + let seen = nodes_newly_allocated_in_current_session.lock().contains(dep_node); + assert!(!seen, "{}", msg()); + }); } } @@ -1133,7 +1136,8 @@ pub(super) struct CurrentDepGraph<D: Deps> { forbidden_edge: Option<EdgeFilter>, /// Used to verify the absence of hash collisions among DepNodes. - /// This field is only `Some` if the `-Z incremental_verify_ich` option is present. + /// This field is only `Some` if the `-Z incremental_verify_ich` option is present + /// or if `debug_assertions` are enabled. /// /// The map contains all DepNodes that have been allocated in the current session so far and /// for which there is no equivalent in the previous session. @@ -1186,6 +1190,9 @@ impl<D: Deps> CurrentDepGraph<D> { let new_node_count_estimate = 102 * prev_graph_node_count / 100 + 200; + let new_node_dbg = + session.opts.unstable_opts.incremental_verify_ich || cfg!(debug_assertions); + CurrentDepGraph { encoder: GraphEncoder::new( encoder, @@ -1207,16 +1214,12 @@ impl<D: Deps> CurrentDepGraph<D> { forbidden_edge, #[cfg(debug_assertions)] fingerprints: Lock::new(IndexVec::from_elem_n(None, new_node_count_estimate)), - nodes_newly_allocated_in_current_session: session - .opts - .unstable_opts - .incremental_verify_ich - .then(|| { - Lock::new(FxHashSet::with_capacity_and_hasher( - new_node_count_estimate, - Default::default(), - )) - }), + nodes_newly_allocated_in_current_session: new_node_dbg.then(|| { + Lock::new(FxHashSet::with_capacity_and_hasher( + new_node_count_estimate, + Default::default(), + )) + }), total_read_count: AtomicU64::new(0), total_duplicate_read_count: AtomicU64::new(0), } @@ -1248,9 +1251,11 @@ impl<D: Deps> CurrentDepGraph<D> { if let Some(ref nodes_newly_allocated_in_current_session) = self.nodes_newly_allocated_in_current_session { - if !nodes_newly_allocated_in_current_session.lock().insert(key) { - panic!("Found duplicate dep-node {key:?}"); - } + outline(|| { + if !nodes_newly_allocated_in_current_session.lock().insert(key) { + panic!("Found duplicate dep-node {key:?}"); + } + }); } dep_node_index |
