Skip to content

Commit ef94d5c

Browse files
committed
Auto merge of #46068 - wesleywiser:incr_duplicate_read_stats, r=michaelwoerister
[incremental] Collect stats about duplicated edge reads from queries Part of #45873
2 parents f50fd07 + 8d6f869 commit ef94d5c

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/librustc/dep_graph/graph.rs

+14
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,12 @@ impl DepGraph {
413413
self.data.as_ref().and_then(|t| t.dep_node_debug.borrow().get(&dep_node).cloned())
414414
}
415415

416+
pub fn edge_deduplication_data(&self) -> (u64, u64) {
417+
let current_dep_graph = self.data.as_ref().unwrap().current.borrow();
418+
419+
(current_dep_graph.total_read_count, current_dep_graph.total_duplicate_read_count)
420+
}
421+
416422
pub fn serialize(&self) -> SerializedDepGraph {
417423
let fingerprints = self.fingerprints.borrow();
418424
let current_dep_graph = self.data.as_ref().unwrap().current.borrow();
@@ -737,6 +743,9 @@ pub(super) struct CurrentDepGraph {
737743
// each anon node. The session-key is just a random number generated when
738744
// the DepGraph is created.
739745
anon_id_seed: Fingerprint,
746+
747+
total_read_count: u64,
748+
total_duplicate_read_count: u64,
740749
}
741750

742751
impl CurrentDepGraph {
@@ -770,6 +779,8 @@ impl CurrentDepGraph {
770779
anon_id_seed: stable_hasher.finish(),
771780
task_stack: Vec::new(),
772781
forbidden_edge,
782+
total_read_count: 0,
783+
total_duplicate_read_count: 0,
773784
}
774785
}
775786

@@ -900,6 +911,7 @@ impl CurrentDepGraph {
900911
ref mut read_set,
901912
node: ref target,
902913
}) => {
914+
self.total_read_count += 1;
903915
if read_set.insert(source) {
904916
reads.push(source);
905917

@@ -913,6 +925,8 @@ impl CurrentDepGraph {
913925
}
914926
}
915927
}
928+
} else {
929+
self.total_duplicate_read_count += 1;
916930
}
917931
}
918932
Some(&mut OpenTask::Anon {

src/librustc_incremental/persist/save.rs

+4
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ fn encode_dep_graph(tcx: TyCtxt,
189189

190190
let total_node_count = serialized_graph.nodes.len();
191191
let total_edge_count = serialized_graph.edge_list_data.len();
192+
let (total_edge_reads, total_duplicate_edge_reads) =
193+
tcx.dep_graph.edge_deduplication_data();
192194

193195
let mut counts: FxHashMap<_, Stat> = FxHashMap();
194196

@@ -226,6 +228,8 @@ fn encode_dep_graph(tcx: TyCtxt,
226228
println!("[incremental]");
227229
println!("[incremental] Total Node Count: {}", total_node_count);
228230
println!("[incremental] Total Edge Count: {}", total_edge_count);
231+
println!("[incremental] Total Edge Reads: {}", total_edge_reads);
232+
println!("[incremental] Total Duplicate Edge Reads: {}", total_duplicate_edge_reads);
229233
println!("[incremental]");
230234
println!("[incremental] {:<36}| {:<17}| {:<12}| {:<17}|",
231235
"Node Kind",

0 commit comments

Comments
 (0)