]> git.lizzy.rs Git - rust.git/commitdiff
Add self profiler events for loading incremental query results from disk
authorWesley Wiser <wwiser@gmail.com>
Thu, 7 Feb 2019 08:58:14 +0000 (09:58 +0100)
committerWesley Wiser <wwiser@gmail.com>
Mon, 11 Feb 2019 23:00:46 +0000 (18:00 -0500)
src/librustc/ty/query/plumbing.rs
src/librustc/util/profiling.rs

index f63fbd79825db482be357e12695cd0591bd57e91..74a7cc5a8b75a0c0729ac65eaa04cdb963bf2d21 100644 (file)
@@ -436,7 +436,9 @@ fn load_from_disk_and_cache_in_memory<Q: QueryDescription<'gcx>>(
         // First we try to load the result from the on-disk cache
         let result = if Q::cache_on_disk(self.global_tcx(), key.clone()) &&
                         self.sess.opts.debugging_opts.incremental_queries {
+            self.sess.profiler(|p| p.incremental_load_result_start(Q::NAME));
             let result = Q::try_load_from_disk(self.global_tcx(), prev_dep_node_index);
+            self.sess.profiler(|p| p.incremental_load_result_end(Q::NAME));
 
             // We always expect to find a cached result for things that
             // can be forced from DepNode.
index f8fa01b6395008beb0abc4748f7ba6e7e8fa1d47..0306ce1e6f29b29bf007f23f44a5bc92269a9a5e 100644 (file)
@@ -25,6 +25,8 @@ pub enum ProfilerEvent {
     GenericActivityEnd { category: ProfileCategory, time: Instant },
     QueryCacheHit { query_name: &'static str, category: ProfileCategory },
     QueryCount { query_name: &'static str, category: ProfileCategory, count: usize },
+    IncrementalLoadResultStart { query_name: &'static str, time: Instant },
+    IncrementalLoadResultEnd { query_name: &'static str, time: Instant },
 }
 
 impl ProfilerEvent {
@@ -32,9 +34,15 @@ fn is_start_event(&self) -> bool {
         use self::ProfilerEvent::*;
 
         match self {
-            QueryStart { .. } | GenericActivityStart { .. } => true,
-            QueryEnd { .. } | GenericActivityEnd { .. } |
-            QueryCacheHit { .. } | QueryCount { .. } => false,
+            QueryStart { .. } |
+            GenericActivityStart { .. } |
+            IncrementalLoadResultStart { .. } => true,
+
+            QueryEnd { .. } |
+            GenericActivityEnd { .. } |
+            QueryCacheHit { .. } |
+            QueryCount { .. } |
+            IncrementalLoadResultEnd { .. } => false,
         }
     }
 }
@@ -225,6 +233,22 @@ pub fn end_query(&mut self, query_name: &'static str, category: ProfileCategory)
         })
     }
 
+    #[inline]
+    pub fn incremental_load_result_start(&mut self, query_name: &'static str) {
+        self.record(ProfilerEvent::IncrementalLoadResultStart {
+            query_name,
+            time: Instant::now(),
+        })
+    }
+
+    #[inline]
+    pub fn incremental_load_result_end(&mut self, query_name: &'static str) {
+        self.record(ProfilerEvent::IncrementalLoadResultEnd {
+            query_name,
+            time: Instant::now(),
+        })
+    }
+
     #[inline]
     fn record(&mut self, event: ProfilerEvent) {
         let thread_id = std::thread::current().id();
@@ -317,6 +341,8 @@ fn calculate_thread_results(events: &Vec<ProfilerEvent>) -> CalculatedResults {
                         result_data.query_cache_stats.entry(query_name).or_insert((0, 0));
                     *totals += *count as u64;
                 },
+                //we don't summarize incremental load result events in the simple output mode
+                IncrementalLoadResultStart { .. } | IncrementalLoadResultEnd { .. } => { },
             }
         }