From f7266341982868a7e94adec3e189284bc7389127 Mon Sep 17 00:00:00 2001 From: Wesley Wiser Date: Sat, 11 Nov 2017 14:32:01 -0500 Subject: [PATCH 1/3] [incremental] Collect stats about duplicated edge reads from queries Part of #45873 --- src/librustc/dep_graph/graph.rs | 14 ++++++++++++++ src/librustc_incremental/persist/save.rs | 3 +++ 2 files changed, 17 insertions(+) diff --git a/src/librustc/dep_graph/graph.rs b/src/librustc/dep_graph/graph.rs index c9205f67f661f..015cdd11bbdf7 100644 --- a/src/librustc/dep_graph/graph.rs +++ b/src/librustc/dep_graph/graph.rs @@ -413,6 +413,12 @@ impl DepGraph { self.data.as_ref().and_then(|t| t.dep_node_debug.borrow().get(&dep_node).cloned()) } + pub fn edge_deduplication_data(&self) -> (u64, u64) { + let current_dep_graph = self.data.as_ref().unwrap().current.borrow(); + + (current_dep_graph.total_read_count, current_dep_graph.total_duplicate_read_count) + } + pub fn serialize(&self) -> SerializedDepGraph { let fingerprints = self.fingerprints.borrow(); let current_dep_graph = self.data.as_ref().unwrap().current.borrow(); @@ -737,6 +743,9 @@ pub(super) struct CurrentDepGraph { // each anon node. The session-key is just a random number generated when // the DepGraph is created. anon_id_seed: Fingerprint, + + total_read_count: u64, + total_duplicate_read_count: u64, } impl CurrentDepGraph { @@ -770,6 +779,8 @@ impl CurrentDepGraph { anon_id_seed: stable_hasher.finish(), task_stack: Vec::new(), forbidden_edge, + total_read_count: 0, + total_duplicate_read_count: 0, } } @@ -900,6 +911,7 @@ impl CurrentDepGraph { ref mut read_set, node: ref target, }) => { + self.total_read_count += 1; if read_set.insert(source) { reads.push(source); @@ -913,6 +925,8 @@ impl CurrentDepGraph { } } } + } else { + self.total_duplicate_read_count += 1; } } Some(&mut OpenTask::Anon { diff --git a/src/librustc_incremental/persist/save.rs b/src/librustc_incremental/persist/save.rs index b6dabf99be7d7..df25c08dd7580 100644 --- a/src/librustc_incremental/persist/save.rs +++ b/src/librustc_incremental/persist/save.rs @@ -189,6 +189,7 @@ fn encode_dep_graph(tcx: TyCtxt, let total_node_count = serialized_graph.nodes.len(); let total_edge_count = serialized_graph.edge_list_data.len(); + let (total_edge_reads, total_duplicate_edge_reads) = tcx.dep_graph.edge_deduplication_data(); let mut counts: FxHashMap<_, Stat> = FxHashMap(); @@ -226,6 +227,8 @@ fn encode_dep_graph(tcx: TyCtxt, println!("[incremental]"); println!("[incremental] Total Node Count: {}", total_node_count); println!("[incremental] Total Edge Count: {}", total_edge_count); + println!("[incremental] Total Edge Reads: {}", total_edge_reads); + println!("[incremental] Total Duplicate Edge Reads: {}", total_duplicate_edge_reads); println!("[incremental]"); println!("[incremental] {:<36}| {:<17}| {:<12}| {:<17}|", "Node Kind", From a4ad5dbcb7d987081ff2465c9c66894676e36c34 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Sun, 19 Nov 2017 17:12:04 +0100 Subject: [PATCH 2/3] Fix tidy line-length issue. --- src/librustc_incremental/persist/save.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/librustc_incremental/persist/save.rs b/src/librustc_incremental/persist/save.rs index df25c08dd7580..c6a2e45cb04b6 100644 --- a/src/librustc_incremental/persist/save.rs +++ b/src/librustc_incremental/persist/save.rs @@ -189,7 +189,8 @@ fn encode_dep_graph(tcx: TyCtxt, let total_node_count = serialized_graph.nodes.len(); let total_edge_count = serialized_graph.edge_list_data.len(); - let (total_edge_reads, total_duplicate_edge_reads) = tcx.dep_graph.edge_deduplication_data(); + let (total_edge_reads, total_duplicate_edge_reads) = + tcx.dep_graph.edge_deduplication_data(); let mut counts: FxHashMap<_, Stat> = FxHashMap(); From 8d6f869c988d0d00ea93ce228b41f30aec3cb102 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Sun, 19 Nov 2017 17:26:19 +0100 Subject: [PATCH 3/3] Remove some trailing whitespace. --- src/librustc_incremental/persist/save.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_incremental/persist/save.rs b/src/librustc_incremental/persist/save.rs index c6a2e45cb04b6..a438ac42838db 100644 --- a/src/librustc_incremental/persist/save.rs +++ b/src/librustc_incremental/persist/save.rs @@ -189,7 +189,7 @@ fn encode_dep_graph(tcx: TyCtxt, let total_node_count = serialized_graph.nodes.len(); let total_edge_count = serialized_graph.edge_list_data.len(); - let (total_edge_reads, total_duplicate_edge_reads) = + let (total_edge_reads, total_duplicate_edge_reads) = tcx.dep_graph.edge_deduplication_data(); let mut counts: FxHashMap<_, Stat> = FxHashMap();