Profile incremental hashing
This commit is contained in:
parent
c5e344f774
commit
6e33dce9c2
3 changed files with 70 additions and 15 deletions
|
@ -94,31 +94,34 @@ use std::process;
|
|||
use std::sync::Arc;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use measureme::{EventId, EventIdBuilder, Profiler, SerializableString, StringId};
|
||||
pub use measureme::EventId;
|
||||
use measureme::{EventIdBuilder, Profiler, SerializableString, StringId};
|
||||
use parking_lot::RwLock;
|
||||
|
||||
bitflags::bitflags! {
|
||||
struct EventFilter: u32 {
|
||||
const GENERIC_ACTIVITIES = 1 << 0;
|
||||
const QUERY_PROVIDERS = 1 << 1;
|
||||
const QUERY_CACHE_HITS = 1 << 2;
|
||||
const QUERY_BLOCKED = 1 << 3;
|
||||
const INCR_CACHE_LOADS = 1 << 4;
|
||||
const GENERIC_ACTIVITIES = 1 << 0;
|
||||
const QUERY_PROVIDERS = 1 << 1;
|
||||
const QUERY_CACHE_HITS = 1 << 2;
|
||||
const QUERY_BLOCKED = 1 << 3;
|
||||
const INCR_CACHE_LOADS = 1 << 4;
|
||||
|
||||
const QUERY_KEYS = 1 << 5;
|
||||
const FUNCTION_ARGS = 1 << 6;
|
||||
const LLVM = 1 << 7;
|
||||
const QUERY_KEYS = 1 << 5;
|
||||
const FUNCTION_ARGS = 1 << 6;
|
||||
const LLVM = 1 << 7;
|
||||
const INCR_RESULT_HASHING = 1 << 8;
|
||||
|
||||
const DEFAULT = Self::GENERIC_ACTIVITIES.bits |
|
||||
Self::QUERY_PROVIDERS.bits |
|
||||
Self::QUERY_BLOCKED.bits |
|
||||
Self::INCR_CACHE_LOADS.bits;
|
||||
Self::INCR_CACHE_LOADS.bits |
|
||||
Self::INCR_RESULT_HASHING.bits;
|
||||
|
||||
const ARGS = Self::QUERY_KEYS.bits | Self::FUNCTION_ARGS.bits;
|
||||
}
|
||||
}
|
||||
|
||||
// keep this in sync with the `-Z self-profile-events` help message in librustc_session/options.rs
|
||||
// keep this in sync with the `-Z self-profile-events` help message in rustc_session/options.rs
|
||||
const EVENT_FILTERS_BY_NAME: &[(&str, EventFilter)] = &[
|
||||
("none", EventFilter::empty()),
|
||||
("all", EventFilter::all()),
|
||||
|
@ -132,6 +135,7 @@ const EVENT_FILTERS_BY_NAME: &[(&str, EventFilter)] = &[
|
|||
("function-args", EventFilter::FUNCTION_ARGS),
|
||||
("args", EventFilter::ARGS),
|
||||
("llvm", EventFilter::LLVM),
|
||||
("incr-result-hashing", EventFilter::INCR_RESULT_HASHING),
|
||||
];
|
||||
|
||||
/// Something that uniquely identifies a query invocation.
|
||||
|
@ -248,6 +252,15 @@ impl SelfProfilerRef {
|
|||
})
|
||||
}
|
||||
|
||||
/// Start profiling with some event filter for a given event. Profiling continues until the
|
||||
/// TimingGuard returned from this call is dropped.
|
||||
#[inline(always)]
|
||||
pub fn generic_activity_with_event(&self, event_id: EventId) -> TimingGuard<'_> {
|
||||
self.exec(EventFilter::GENERIC_ACTIVITIES, |profiler| {
|
||||
TimingGuard::start(profiler, profiler.generic_activity_event_kind, event_id)
|
||||
})
|
||||
}
|
||||
|
||||
/// Start profiling a generic activity. Profiling continues until the
|
||||
/// TimingGuard returned from this call is dropped.
|
||||
#[inline(always)]
|
||||
|
@ -337,6 +350,19 @@ impl SelfProfilerRef {
|
|||
})
|
||||
}
|
||||
|
||||
/// Start profiling how long it takes to hash query results for incremental compilation.
|
||||
/// Profiling continues until the TimingGuard returned from this call is dropped.
|
||||
#[inline(always)]
|
||||
pub fn incr_result_hashing(&self) -> TimingGuard<'_> {
|
||||
self.exec(EventFilter::INCR_RESULT_HASHING, |profiler| {
|
||||
TimingGuard::start(
|
||||
profiler,
|
||||
profiler.incremental_result_hashing_event_kind,
|
||||
EventId::INVALID,
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn instant_query_event(
|
||||
&self,
|
||||
|
@ -364,6 +390,10 @@ impl SelfProfilerRef {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_or_alloc_cached_string(&self, s: &'static str) -> Option<StringId> {
|
||||
self.profiler.as_ref().map(|p| p.get_or_alloc_cached_string(s))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn enabled(&self) -> bool {
|
||||
self.profiler.is_some()
|
||||
|
@ -388,6 +418,7 @@ pub struct SelfProfiler {
|
|||
query_event_kind: StringId,
|
||||
generic_activity_event_kind: StringId,
|
||||
incremental_load_result_event_kind: StringId,
|
||||
incremental_result_hashing_event_kind: StringId,
|
||||
query_blocked_event_kind: StringId,
|
||||
query_cache_hit_event_kind: StringId,
|
||||
}
|
||||
|
@ -408,6 +439,8 @@ impl SelfProfiler {
|
|||
let query_event_kind = profiler.alloc_string("Query");
|
||||
let generic_activity_event_kind = profiler.alloc_string("GenericActivity");
|
||||
let incremental_load_result_event_kind = profiler.alloc_string("IncrementalLoadResult");
|
||||
let incremental_result_hashing_event_kind =
|
||||
profiler.alloc_string("IncrementalResultHashing");
|
||||
let query_blocked_event_kind = profiler.alloc_string("QueryBlocked");
|
||||
let query_cache_hit_event_kind = profiler.alloc_string("QueryCacheHit");
|
||||
|
||||
|
@ -451,6 +484,7 @@ impl SelfProfiler {
|
|||
query_event_kind,
|
||||
generic_activity_event_kind,
|
||||
incremental_load_result_event_kind,
|
||||
incremental_result_hashing_event_kind,
|
||||
query_blocked_event_kind,
|
||||
query_cache_hit_event_kind,
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue