Skip to content

Commit ae044ee

Browse files
committed
Add self profiler events for loading incremental query results from disk
1 parent 57d7cfc commit ae044ee

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

src/librustc/ty/query/plumbing.rs

+2
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
436436
// First we try to load the result from the on-disk cache
437437
let result = if Q::cache_on_disk(self.global_tcx(), key.clone()) &&
438438
self.sess.opts.debugging_opts.incremental_queries {
439+
self.sess.profiler(|p| p.incremental_load_result_start(Q::NAME));
439440
let result = Q::try_load_from_disk(self.global_tcx(), prev_dep_node_index);
441+
self.sess.profiler(|p| p.incremental_load_result_end(Q::NAME));
440442

441443
// We always expect to find a cached result for things that
442444
// can be forced from DepNode.

src/librustc/util/profiling.rs

+29-3
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,24 @@ pub enum ProfilerEvent {
2525
GenericActivityEnd { category: ProfileCategory, time: Instant },
2626
QueryCacheHit { query_name: &'static str, category: ProfileCategory },
2727
QueryCount { query_name: &'static str, category: ProfileCategory, count: usize },
28+
IncrementalLoadResultStart { query_name: &'static str, time: Instant },
29+
IncrementalLoadResultEnd { query_name: &'static str, time: Instant },
2830
}
2931

3032
impl ProfilerEvent {
3133
fn is_start_event(&self) -> bool {
3234
use self::ProfilerEvent::*;
3335

3436
match self {
35-
QueryStart { .. } | GenericActivityStart { .. } => true,
36-
QueryEnd { .. } | GenericActivityEnd { .. } |
37-
QueryCacheHit { .. } | QueryCount { .. } => false,
37+
QueryStart { .. } |
38+
GenericActivityStart { .. } |
39+
IncrementalLoadResultStart { .. } => true,
40+
41+
QueryEnd { .. } |
42+
GenericActivityEnd { .. } |
43+
QueryCacheHit { .. } |
44+
QueryCount { .. } |
45+
IncrementalLoadResultEnd { .. } => false,
3846
}
3947
}
4048
}
@@ -225,6 +233,22 @@ impl SelfProfiler {
225233
})
226234
}
227235

236+
#[inline]
237+
pub fn incremental_load_result_start(&mut self, query_name: &'static str) {
238+
self.record(ProfilerEvent::IncrementalLoadResultStart {
239+
query_name,
240+
time: Instant::now(),
241+
})
242+
}
243+
244+
#[inline]
245+
pub fn incremental_load_result_end(&mut self, query_name: &'static str) {
246+
self.record(ProfilerEvent::IncrementalLoadResultEnd {
247+
query_name,
248+
time: Instant::now(),
249+
})
250+
}
251+
228252
#[inline]
229253
fn record(&mut self, event: ProfilerEvent) {
230254
let thread_id = std::thread::current().id();
@@ -317,6 +341,8 @@ impl SelfProfiler {
317341
result_data.query_cache_stats.entry(query_name).or_insert((0, 0));
318342
*totals += *count as u64;
319343
},
344+
//we don't summarize incremental load result events in the simple output mode
345+
IncrementalLoadResultStart { .. } | IncrementalLoadResultEnd { .. } => { },
320346
}
321347
}
322348

0 commit comments

Comments
 (0)