about summary refs log tree commit diff
diff options
context:
space:
mode:
authorWesley Wiser <wwiser@gmail.com>2019-02-07 09:58:14 +0100
committerWesley Wiser <wwiser@gmail.com>2019-02-11 18:00:46 -0500
commitae044ee893edca63488fe020900b88909bae9832 (patch)
treee123f6d2f33ab93bf4bb73e94fb60ec91e32bf36
parent57d7cfc3cf50f0c427ad3043ff09eaef20671320 (diff)
downloadrust-ae044ee893edca63488fe020900b88909bae9832.tar.gz
rust-ae044ee893edca63488fe020900b88909bae9832.zip
Add self profiler events for loading incremental query results from disk
-rw-r--r--src/librustc/ty/query/plumbing.rs2
-rw-r--r--src/librustc/util/profiling.rs32
2 files changed, 31 insertions, 3 deletions
diff --git a/src/librustc/ty/query/plumbing.rs b/src/librustc/ty/query/plumbing.rs
index f63fbd79825..74a7cc5a8b7 100644
--- a/src/librustc/ty/query/plumbing.rs
+++ b/src/librustc/ty/query/plumbing.rs
@@ -436,7 +436,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
         // 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.
diff --git a/src/librustc/util/profiling.rs b/src/librustc/util/profiling.rs
index f8fa01b6395..0306ce1e6f2 100644
--- a/src/librustc/util/profiling.rs
+++ b/src/librustc/util/profiling.rs
@@ -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 @@ impl ProfilerEvent {
         use self::ProfilerEvent::*;
 
         match self {
-            QueryStart { .. } | GenericActivityStart { .. } => true,
-            QueryEnd { .. } | GenericActivityEnd { .. } |
-            QueryCacheHit { .. } | QueryCount { .. } => false,
+            QueryStart { .. } |
+            GenericActivityStart { .. } |
+            IncrementalLoadResultStart { .. } => true,
+
+            QueryEnd { .. } |
+            GenericActivityEnd { .. } |
+            QueryCacheHit { .. } |
+            QueryCount { .. } |
+            IncrementalLoadResultEnd { .. } => false,
         }
     }
 }
@@ -226,6 +234,22 @@ impl SelfProfiler {
     }
 
     #[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();
         let events = self.events.entry(thread_id).or_default();
@@ -317,6 +341,8 @@ impl SelfProfiler {
                         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 { .. } => { },
             }
         }