11use rustc_data_structures:: fingerprint:: Fingerprint ;
22use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
3- use rustc_data_structures:: profiling:: { EventId , QueryInvocationId , SelfProfilerRef } ;
3+ use rustc_data_structures:: profiling:: { QueryInvocationId , SelfProfilerRef } ;
44use rustc_data_structures:: sharded:: { self , Sharded } ;
55use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
6- use rustc_data_structures:: steal:: Steal ;
76use rustc_data_structures:: sync:: { AtomicU32 , AtomicU64 , Lock , Lrc } ;
87use rustc_data_structures:: unord:: UnordMap ;
98use rustc_index:: IndexVec ;
@@ -134,7 +133,6 @@ impl<D: Deps> DepGraph<D> {
134133
135134 // Instantiate a dependy-less node only once for anonymous queries.
136135 let _green_node_index = current. intern_new_node (
137- profiler,
138136 DepNode { kind : D :: DEP_KIND_NULL , hash : current. anon_id_seed . into ( ) } ,
139137 EdgesVec :: new ( ) ,
140138 Fingerprint :: ZERO ,
@@ -143,7 +141,6 @@ impl<D: Deps> DepGraph<D> {
143141
144142 // Instantiate a dependy-less red node only once for anonymous queries.
145143 let ( red_node_index, red_node_prev_index_and_color) = current. intern_node (
146- profiler,
147144 & prev_graph,
148145 DepNode { kind : D :: DEP_KIND_RED , hash : Fingerprint :: ZERO . into ( ) } ,
149146 EdgesVec :: new ( ) ,
@@ -196,7 +193,7 @@ impl<D: Deps> DepGraph<D> {
196193
197194 pub fn with_query ( & self , f : impl Fn ( & DepGraphQuery ) ) {
198195 if let Some ( data) = & self . data {
199- data. current . encoder . borrow ( ) . with_query ( f)
196+ data. current . encoder . with_query ( f)
200197 }
201198 }
202199
@@ -372,13 +369,8 @@ impl<D: Deps> DepGraphData<D> {
372369 hash_result. map ( |f| dcx. with_stable_hashing_context ( |mut hcx| f ( & mut hcx, & result) ) ) ;
373370
374371 // Intern the new `DepNode`.
375- let ( dep_node_index, prev_and_color) = self . current . intern_node (
376- dcx. profiler ( ) ,
377- & self . previous ,
378- key,
379- edges,
380- current_fingerprint,
381- ) ;
372+ let ( dep_node_index, prev_and_color) =
373+ self . current . intern_node ( & self . previous , key, edges, current_fingerprint) ;
382374
383375 hashing_timer. finish_with_query_invocation_id ( dep_node_index. into ( ) ) ;
384376
@@ -443,12 +435,7 @@ impl<D: Deps> DepGraphData<D> {
443435 hash : self . current . anon_id_seed . combine ( hasher. finish ( ) ) . into ( ) ,
444436 } ;
445437
446- self . current . intern_new_node (
447- cx. profiler ( ) ,
448- target_dep_node,
449- task_deps,
450- Fingerprint :: ZERO ,
451- )
438+ self . current . intern_new_node ( target_dep_node, task_deps, Fingerprint :: ZERO )
452439 }
453440 } ;
454441
@@ -585,13 +572,8 @@ impl<D: Deps> DepGraph<D> {
585572 } ) ;
586573
587574 // Intern the new `DepNode` with the dependencies up-to-now.
588- let ( dep_node_index, prev_and_color) = data. current . intern_node (
589- cx. profiler ( ) ,
590- & data. previous ,
591- node,
592- edges,
593- current_fingerprint,
594- ) ;
575+ let ( dep_node_index, prev_and_color) =
576+ data. current . intern_node ( & data. previous , node, edges, current_fingerprint) ;
595577
596578 hashing_timer. finish_with_query_invocation_id ( dep_node_index. into ( ) ) ;
597579
@@ -871,11 +853,8 @@ impl<D: Deps> DepGraphData<D> {
871853
872854 // We allocating an entry for the node in the current dependency graph and
873855 // adding all the appropriate edges imported from the previous graph
874- let dep_node_index = self . current . promote_node_and_deps_to_current (
875- qcx. dep_context ( ) . profiler ( ) ,
876- & self . previous ,
877- prev_dep_node_index,
878- ) ;
856+ let dep_node_index =
857+ self . current . promote_node_and_deps_to_current ( & self . previous , prev_dep_node_index) ;
879858
880859 // ... emitting any stored diagnostic ...
881860
@@ -974,19 +953,15 @@ impl<D: Deps> DepGraph<D> {
974953
975954 pub fn print_incremental_info ( & self ) {
976955 if let Some ( data) = & self . data {
977- data. current . encoder . borrow ( ) . print_incremental_info (
956+ data. current . encoder . print_incremental_info (
978957 data. current . total_read_count . load ( Ordering :: Relaxed ) ,
979958 data. current . total_duplicate_read_count . load ( Ordering :: Relaxed ) ,
980959 )
981960 }
982961 }
983962
984- pub fn finish_encoding ( & self , profiler : & SelfProfilerRef ) -> FileEncodeResult {
985- if let Some ( data) = & self . data {
986- data. current . encoder . steal ( ) . finish ( profiler)
987- } else {
988- Ok ( 0 )
989- }
963+ pub fn finish_encoding ( & self ) -> FileEncodeResult {
964+ if let Some ( data) = & self . data { data. current . encoder . finish ( ) } else { Ok ( 0 ) }
990965 }
991966
992967 pub ( crate ) fn next_virtual_depnode_index ( & self ) -> DepNodeIndex {
@@ -1069,7 +1044,7 @@ rustc_index::newtype_index! {
10691044/// manipulating both, we acquire `new_node_to_index` or `prev_index_to_index`
10701045/// first, and `data` second.
10711046pub ( super ) struct CurrentDepGraph < D : Deps > {
1072- encoder : Steal < GraphEncoder < D > > ,
1047+ encoder : GraphEncoder < D > ,
10731048 new_node_to_index : Sharded < FxHashMap < DepNode , DepNodeIndex > > ,
10741049 prev_index_to_index : Lock < IndexVec < SerializedDepNodeIndex , Option < DepNodeIndex > > > ,
10751050
@@ -1100,12 +1075,6 @@ pub(super) struct CurrentDepGraph<D: Deps> {
11001075 /// debugging and only active with `debug_assertions`.
11011076 total_read_count : AtomicU64 ,
11021077 total_duplicate_read_count : AtomicU64 ,
1103-
1104- /// The cached event id for profiling node interning. This saves us
1105- /// from having to look up the event id every time we intern a node
1106- /// which may incur too much overhead.
1107- /// This will be None if self-profiling is disabled.
1108- node_intern_event_id : Option < EventId > ,
11091078}
11101079
11111080impl < D : Deps > CurrentDepGraph < D > {
@@ -1140,17 +1109,14 @@ impl<D: Deps> CurrentDepGraph<D> {
11401109
11411110 let new_node_count_estimate = 102 * prev_graph_node_count / 100 + 200 ;
11421111
1143- let node_intern_event_id = profiler
1144- . get_or_alloc_cached_string ( "incr_comp_intern_dep_graph_node" )
1145- . map ( EventId :: from_label) ;
1146-
11471112 CurrentDepGraph {
1148- encoder : Steal :: new ( GraphEncoder :: new (
1113+ encoder : GraphEncoder :: new (
11491114 encoder,
11501115 prev_graph_node_count,
11511116 record_graph,
11521117 record_stats,
1153- ) ) ,
1118+ profiler,
1119+ ) ,
11541120 new_node_to_index : Sharded :: new ( || {
11551121 FxHashMap :: with_capacity_and_hasher (
11561122 new_node_count_estimate / sharded:: shards ( ) ,
@@ -1165,7 +1131,6 @@ impl<D: Deps> CurrentDepGraph<D> {
11651131 fingerprints : Lock :: new ( IndexVec :: from_elem_n ( None , new_node_count_estimate) ) ,
11661132 total_read_count : AtomicU64 :: new ( 0 ) ,
11671133 total_duplicate_read_count : AtomicU64 :: new ( 0 ) ,
1168- node_intern_event_id,
11691134 }
11701135 }
11711136
@@ -1183,16 +1148,14 @@ impl<D: Deps> CurrentDepGraph<D> {
11831148 #[ inline( always) ]
11841149 fn intern_new_node (
11851150 & self ,
1186- profiler : & SelfProfilerRef ,
11871151 key : DepNode ,
11881152 edges : EdgesVec ,
11891153 current_fingerprint : Fingerprint ,
11901154 ) -> DepNodeIndex {
11911155 let dep_node_index = match self . new_node_to_index . lock_shard_by_value ( & key) . entry ( key) {
11921156 Entry :: Occupied ( entry) => * entry. get ( ) ,
11931157 Entry :: Vacant ( entry) => {
1194- let dep_node_index =
1195- self . encoder . borrow ( ) . send ( profiler, key, current_fingerprint, edges) ;
1158+ let dep_node_index = self . encoder . send ( key, current_fingerprint, edges) ;
11961159 entry. insert ( dep_node_index) ;
11971160 dep_node_index
11981161 }
@@ -1206,25 +1169,19 @@ impl<D: Deps> CurrentDepGraph<D> {
12061169
12071170 fn intern_node (
12081171 & self ,
1209- profiler : & SelfProfilerRef ,
12101172 prev_graph : & SerializedDepGraph ,
12111173 key : DepNode ,
12121174 edges : EdgesVec ,
12131175 fingerprint : Option < Fingerprint > ,
12141176 ) -> ( DepNodeIndex , Option < ( SerializedDepNodeIndex , DepNodeColor ) > ) {
1215- // Get timer for profiling `DepNode` interning
1216- let _node_intern_timer =
1217- self . node_intern_event_id . map ( |eid| profiler. generic_activity_with_event_id ( eid) ) ;
1218-
12191177 if let Some ( prev_index) = prev_graph. node_to_index_opt ( & key) {
12201178 let get_dep_node_index = |fingerprint| {
12211179 let mut prev_index_to_index = self . prev_index_to_index . lock ( ) ;
12221180
12231181 let dep_node_index = match prev_index_to_index[ prev_index] {
12241182 Some ( dep_node_index) => dep_node_index,
12251183 None => {
1226- let dep_node_index =
1227- self . encoder . borrow ( ) . send ( profiler, key, fingerprint, edges) ;
1184+ let dep_node_index = self . encoder . send ( key, fingerprint, edges) ;
12281185 prev_index_to_index[ prev_index] = Some ( dep_node_index) ;
12291186 dep_node_index
12301187 }
@@ -1261,15 +1218,14 @@ impl<D: Deps> CurrentDepGraph<D> {
12611218 let fingerprint = fingerprint. unwrap_or ( Fingerprint :: ZERO ) ;
12621219
12631220 // This is a new node: it didn't exist in the previous compilation session.
1264- let dep_node_index = self . intern_new_node ( profiler , key, edges, fingerprint) ;
1221+ let dep_node_index = self . intern_new_node ( key, edges, fingerprint) ;
12651222
12661223 ( dep_node_index, None )
12671224 }
12681225 }
12691226
12701227 fn promote_node_and_deps_to_current (
12711228 & self ,
1272- profiler : & SelfProfilerRef ,
12731229 prev_graph : & SerializedDepGraph ,
12741230 prev_index : SerializedDepNodeIndex ,
12751231 ) -> DepNodeIndex {
@@ -1286,7 +1242,7 @@ impl<D: Deps> CurrentDepGraph<D> {
12861242 . map ( |i| prev_index_to_index[ i] . unwrap ( ) )
12871243 . collect ( ) ;
12881244 let fingerprint = prev_graph. fingerprint_by_index ( prev_index) ;
1289- let dep_node_index = self . encoder . borrow ( ) . send ( profiler , key, fingerprint, edges) ;
1245+ let dep_node_index = self . encoder . send ( key, fingerprint, edges) ;
12901246 prev_index_to_index[ prev_index] = Some ( dep_node_index) ;
12911247 #[ cfg( debug_assertions) ]
12921248 self . record_edge ( dep_node_index, key, fingerprint) ;
0 commit comments