]> git.lizzy.rs Git - rust.git/commitdiff
[incremental] Collect stats about duplicated edge reads from queries
authorWesley Wiser <wwiser@gmail.com>
Sat, 11 Nov 2017 19:32:01 +0000 (14:32 -0500)
committerWesley Wiser <wwiser@gmail.com>
Fri, 17 Nov 2017 23:03:29 +0000 (18:03 -0500)
Part of #45873

src/librustc/dep_graph/graph.rs
src/librustc_incremental/persist/save.rs

index c9205f67f661f2b9ccf5f0b2a9b4349960aa5cff..015cdd11bbdf778ea727473fcecb9f405c4d8870 100644 (file)
@@ -413,6 +413,12 @@ pub(super) fn dep_node_debug_str(&self, dep_node: DepNode) -> Option<String> {
         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 @@ fn new() -> 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 @@ fn read_index(&mut self, source: DepNodeIndex) {
                 ref mut read_set,
                 node: ref target,
             }) => {
+                self.total_read_count += 1;
                 if read_set.insert(source) {
                     reads.push(source);
 
@@ -913,6 +925,8 @@ fn read_index(&mut self, source: DepNodeIndex) {
                             }
                         }
                     }
+                } else {
+                    self.total_duplicate_read_count += 1;
                 }
             }
             Some(&mut OpenTask::Anon {
index b6dabf99be7d7d7468bcae9d93eac80baf7e152a..df25c08dd7580e047b332b53533a8713ac8702ba 100644 (file)
@@ -189,6 +189,7 @@ struct Stat {
 
         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 @@ struct Stat {
         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",