1
1
use rustc_data_structures:: fingerprint:: Fingerprint ;
2
2
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
3
- use rustc_data_structures:: profiling:: { EventId , QueryInvocationId , SelfProfilerRef } ;
3
+ use rustc_data_structures:: profiling:: { QueryInvocationId , SelfProfilerRef } ;
4
4
use rustc_data_structures:: sharded:: { self , Sharded } ;
5
5
use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
6
- use rustc_data_structures:: steal:: Steal ;
7
6
use rustc_data_structures:: sync:: { AtomicU32 , AtomicU64 , Lock , Lrc } ;
8
7
use rustc_data_structures:: unord:: UnordMap ;
9
8
use rustc_index:: IndexVec ;
@@ -134,7 +133,6 @@ impl<D: Deps> DepGraph<D> {
134
133
135
134
// Instantiate a dependy-less node only once for anonymous queries.
136
135
let _green_node_index = current. intern_new_node (
137
- profiler,
138
136
DepNode { kind : D :: DEP_KIND_NULL , hash : current. anon_id_seed . into ( ) } ,
139
137
EdgesVec :: new ( ) ,
140
138
Fingerprint :: ZERO ,
@@ -143,7 +141,6 @@ impl<D: Deps> DepGraph<D> {
143
141
144
142
// Instantiate a dependy-less red node only once for anonymous queries.
145
143
let ( red_node_index, red_node_prev_index_and_color) = current. intern_node (
146
- profiler,
147
144
& prev_graph,
148
145
DepNode { kind : D :: DEP_KIND_RED , hash : Fingerprint :: ZERO . into ( ) } ,
149
146
EdgesVec :: new ( ) ,
@@ -196,7 +193,7 @@ impl<D: Deps> DepGraph<D> {
196
193
197
194
pub fn with_query ( & self , f : impl Fn ( & DepGraphQuery ) ) {
198
195
if let Some ( data) = & self . data {
199
- data. current . encoder . borrow ( ) . with_query ( f)
196
+ data. current . encoder . with_query ( f)
200
197
}
201
198
}
202
199
@@ -372,13 +369,8 @@ impl<D: Deps> DepGraphData<D> {
372
369
hash_result. map ( |f| dcx. with_stable_hashing_context ( |mut hcx| f ( & mut hcx, & result) ) ) ;
373
370
374
371
// 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) ;
382
374
383
375
hashing_timer. finish_with_query_invocation_id ( dep_node_index. into ( ) ) ;
384
376
@@ -443,12 +435,7 @@ impl<D: Deps> DepGraphData<D> {
443
435
hash : self . current . anon_id_seed . combine ( hasher. finish ( ) ) . into ( ) ,
444
436
} ;
445
437
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 )
452
439
}
453
440
} ;
454
441
@@ -585,13 +572,8 @@ impl<D: Deps> DepGraph<D> {
585
572
} ) ;
586
573
587
574
// 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) ;
595
577
596
578
hashing_timer. finish_with_query_invocation_id ( dep_node_index. into ( ) ) ;
597
579
@@ -871,11 +853,8 @@ impl<D: Deps> DepGraphData<D> {
871
853
872
854
// We allocating an entry for the node in the current dependency graph and
873
855
// 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) ;
879
858
880
859
// ... emitting any stored diagnostic ...
881
860
@@ -974,19 +953,15 @@ impl<D: Deps> DepGraph<D> {
974
953
975
954
pub fn print_incremental_info ( & self ) {
976
955
if let Some ( data) = & self . data {
977
- data. current . encoder . borrow ( ) . print_incremental_info (
956
+ data. current . encoder . print_incremental_info (
978
957
data. current . total_read_count . load ( Ordering :: Relaxed ) ,
979
958
data. current . total_duplicate_read_count . load ( Ordering :: Relaxed ) ,
980
959
)
981
960
}
982
961
}
983
962
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 ) }
990
965
}
991
966
992
967
pub ( crate ) fn next_virtual_depnode_index ( & self ) -> DepNodeIndex {
@@ -1069,7 +1044,7 @@ rustc_index::newtype_index! {
1069
1044
/// manipulating both, we acquire `new_node_to_index` or `prev_index_to_index`
1070
1045
/// first, and `data` second.
1071
1046
pub ( super ) struct CurrentDepGraph < D : Deps > {
1072
- encoder : Steal < GraphEncoder < D > > ,
1047
+ encoder : GraphEncoder < D > ,
1073
1048
new_node_to_index : Sharded < FxHashMap < DepNode , DepNodeIndex > > ,
1074
1049
prev_index_to_index : Lock < IndexVec < SerializedDepNodeIndex , Option < DepNodeIndex > > > ,
1075
1050
@@ -1100,12 +1075,6 @@ pub(super) struct CurrentDepGraph<D: Deps> {
1100
1075
/// debugging and only active with `debug_assertions`.
1101
1076
total_read_count : AtomicU64 ,
1102
1077
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 > ,
1109
1078
}
1110
1079
1111
1080
impl < D : Deps > CurrentDepGraph < D > {
@@ -1140,17 +1109,14 @@ impl<D: Deps> CurrentDepGraph<D> {
1140
1109
1141
1110
let new_node_count_estimate = 102 * prev_graph_node_count / 100 + 200 ;
1142
1111
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
-
1147
1112
CurrentDepGraph {
1148
- encoder : Steal :: new ( GraphEncoder :: new (
1113
+ encoder : GraphEncoder :: new (
1149
1114
encoder,
1150
1115
prev_graph_node_count,
1151
1116
record_graph,
1152
1117
record_stats,
1153
- ) ) ,
1118
+ profiler,
1119
+ ) ,
1154
1120
new_node_to_index : Sharded :: new ( || {
1155
1121
FxHashMap :: with_capacity_and_hasher (
1156
1122
new_node_count_estimate / sharded:: shards ( ) ,
@@ -1165,7 +1131,6 @@ impl<D: Deps> CurrentDepGraph<D> {
1165
1131
fingerprints : Lock :: new ( IndexVec :: from_elem_n ( None , new_node_count_estimate) ) ,
1166
1132
total_read_count : AtomicU64 :: new ( 0 ) ,
1167
1133
total_duplicate_read_count : AtomicU64 :: new ( 0 ) ,
1168
- node_intern_event_id,
1169
1134
}
1170
1135
}
1171
1136
@@ -1183,16 +1148,14 @@ impl<D: Deps> CurrentDepGraph<D> {
1183
1148
#[ inline( always) ]
1184
1149
fn intern_new_node (
1185
1150
& self ,
1186
- profiler : & SelfProfilerRef ,
1187
1151
key : DepNode ,
1188
1152
edges : EdgesVec ,
1189
1153
current_fingerprint : Fingerprint ,
1190
1154
) -> DepNodeIndex {
1191
1155
let dep_node_index = match self . new_node_to_index . lock_shard_by_value ( & key) . entry ( key) {
1192
1156
Entry :: Occupied ( entry) => * entry. get ( ) ,
1193
1157
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) ;
1196
1159
entry. insert ( dep_node_index) ;
1197
1160
dep_node_index
1198
1161
}
@@ -1206,25 +1169,19 @@ impl<D: Deps> CurrentDepGraph<D> {
1206
1169
1207
1170
fn intern_node (
1208
1171
& self ,
1209
- profiler : & SelfProfilerRef ,
1210
1172
prev_graph : & SerializedDepGraph ,
1211
1173
key : DepNode ,
1212
1174
edges : EdgesVec ,
1213
1175
fingerprint : Option < Fingerprint > ,
1214
1176
) -> ( 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
-
1219
1177
if let Some ( prev_index) = prev_graph. node_to_index_opt ( & key) {
1220
1178
let get_dep_node_index = |fingerprint| {
1221
1179
let mut prev_index_to_index = self . prev_index_to_index . lock ( ) ;
1222
1180
1223
1181
let dep_node_index = match prev_index_to_index[ prev_index] {
1224
1182
Some ( dep_node_index) => dep_node_index,
1225
1183
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) ;
1228
1185
prev_index_to_index[ prev_index] = Some ( dep_node_index) ;
1229
1186
dep_node_index
1230
1187
}
@@ -1261,15 +1218,14 @@ impl<D: Deps> CurrentDepGraph<D> {
1261
1218
let fingerprint = fingerprint. unwrap_or ( Fingerprint :: ZERO ) ;
1262
1219
1263
1220
// 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) ;
1265
1222
1266
1223
( dep_node_index, None )
1267
1224
}
1268
1225
}
1269
1226
1270
1227
fn promote_node_and_deps_to_current (
1271
1228
& self ,
1272
- profiler : & SelfProfilerRef ,
1273
1229
prev_graph : & SerializedDepGraph ,
1274
1230
prev_index : SerializedDepNodeIndex ,
1275
1231
) -> DepNodeIndex {
@@ -1286,7 +1242,7 @@ impl<D: Deps> CurrentDepGraph<D> {
1286
1242
. map ( |i| prev_index_to_index[ i] . unwrap ( ) )
1287
1243
. collect ( ) ;
1288
1244
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) ;
1290
1246
prev_index_to_index[ prev_index] = Some ( dep_node_index) ;
1291
1247
#[ cfg( debug_assertions) ]
1292
1248
self . record_edge ( dep_node_index, key, fingerprint) ;
0 commit comments