提交 9c083068 编写于 作者: M Michael Woerister

self-profiling: Switch query-blocking measurements to RAII-style API.

上级 ee1173a8
......@@ -90,6 +90,10 @@ pub(super) fn try_get(tcx: TyCtxt<'tcx>, span: Span, key: &Q::Key) -> TryGetJob<
}
return TryGetJob::JobCompleted(result);
}
#[cfg(parallel_compiler)]
let query_blocked_prof_timer;
let job = match lock.active.entry((*key).clone()) {
Entry::Occupied(entry) => {
match *entry.get() {
......@@ -98,7 +102,9 @@ pub(super) fn try_get(tcx: TyCtxt<'tcx>, span: Span, key: &Q::Key) -> TryGetJob<
// in another thread has completed. Record how long we wait in the
// self-profiler.
#[cfg(parallel_compiler)]
tcx.prof.query_blocked_start(Q::NAME);
{
query_blocked_prof_timer = tcx.prof.query_blocked(Q::NAME);
}
job.clone()
},
......@@ -140,7 +146,11 @@ pub(super) fn try_get(tcx: TyCtxt<'tcx>, span: Span, key: &Q::Key) -> TryGetJob<
#[cfg(parallel_compiler)]
{
let result = job.r#await(tcx, span);
tcx.prof.query_blocked_end(Q::NAME);
// This `drop()` is not strictly necessary as the binding
// would go out of scope anyway. But it's good to have an
// explicit marker of how far the measurement goes.
drop(query_blocked_prof_timer);
if let Err(cycle) = result {
return TryGetJob::Cycle(Q::handle_cycle_error(tcx, cycle));
......
......@@ -156,26 +156,14 @@ pub fn query_cache_hit(&self, query_name: QueryName) {
}
/// Start profiling a query being blocked on a concurrent execution.
/// Profiling continues until `query_blocked_end` is called.
/// Profiling continues until the TimingGuard returned from this call is
/// dropped.
#[inline(always)]
pub fn query_blocked_start(&self, query_name: QueryName) {
self.non_guard_query_event(
|profiler| profiler.query_blocked_event_kind,
query_name,
EventFilter::QUERY_BLOCKED,
TimestampKind::Start,
);
}
/// End profiling a query being blocked on a concurrent execution.
#[inline(always)]
pub fn query_blocked_end(&self, query_name: QueryName) {
self.non_guard_query_event(
|profiler| profiler.query_blocked_event_kind,
query_name,
EventFilter::QUERY_BLOCKED,
TimestampKind::End,
);
pub fn query_blocked(&self, query_name: QueryName) -> TimingGuard<'_> {
self.exec(EventFilter::QUERY_BLOCKED, |profiler| {
let event_id = SelfProfiler::get_query_name_string_id(query_name);
TimingGuard::start(profiler, profiler.query_blocked_event_kind, event_id)
})
}
/// Start profiling how long it takes to load a query result from the
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册