1
Fork 0

self-profiling: Add events for everything except trait selection.

This commit is contained in:
Michael Woerister 2019-10-08 14:05:41 +02:00
parent 275cf4bcac
commit ceb1a9cfe3
9 changed files with 39 additions and 4 deletions

View file

@ -845,6 +845,8 @@ impl DepGraph {
// This method will only load queries that will end up in the disk cache.
// Other queries will not be executed.
pub fn exec_cache_promotions(&self, tcx: TyCtxt<'_>) {
let _prof_timer = tcx.prof.generic_activity("incr_comp_query_cache_promotion");
let data = self.data.as_ref().unwrap();
for prev_index in data.colors.values.indices() {
match data.colors.get(prev_index) {

View file

@ -242,6 +242,8 @@ pub fn lower_crate(
// incr. comp. yet.
dep_graph.assert_ignored();
let _prof_timer = sess.prof.generic_activity("hir_lowering");
LoweringContext {
crate_root: sess.parse_sess.injected_crate_name.try_get().copied(),
sess,

View file

@ -1222,6 +1222,8 @@ pub fn map_crate<'hir>(sess: &crate::session::Session,
forest: &'hir Forest,
definitions: &'hir Definitions)
-> Map<'hir> {
let _prof_timer = sess.prof.generic_activity("build_hir_map");
// Build the reverse mapping of `node_to_hir_id`.
let hir_to_node_id = definitions.node_to_hir_id.iter_enumerated()
.map(|(node_id, &hir_id)| (hir_id, node_id)).collect();

View file

@ -101,6 +101,7 @@ pub fn load_dep_graph(sess: &Session) -> DepGraphFuture {
// before we fire the background thread.
let time_passes = sess.time_passes();
let prof = sess.prof.clone();
if sess.opts.incremental.is_none() {
// No incremental compilation.
@ -161,6 +162,8 @@ pub fn load_dep_graph(sess: &Session) -> DepGraphFuture {
MaybeAsync::Async(std::thread::spawn(move || {
time_ext(time_passes, "background load prev dep-graph", move || {
let _prof_timer = prof.generic_activity("incr_comp_load_dep_graph");
match load_data(report_incremental_info, &path) {
LoadResult::DataOutOfDate => LoadResult::DataOutOfDate,
LoadResult::Error { message } => LoadResult::Error { message },
@ -198,6 +201,8 @@ pub fn load_query_result_cache(sess: &Session) -> OnDiskCache<'_> {
return OnDiskCache::new_empty(sess.source_map());
}
let _prof_timer = sess.prof.generic_activity("incr_comp_load_query_result_cache");
match load_data(sess.opts.debugging_opts.incremental_info, &query_cache_path(sess)) {
LoadResult::Ok{ data: (bytes, start_pos) } => OnDiskCache::new(sess, bytes, start_pos),
_ => OnDiskCache::new_empty(sess.source_map())

View file

@ -241,6 +241,8 @@ fn encode_work_product_index(work_products: &FxHashMap<WorkProductId, WorkProduc
fn encode_query_cache(tcx: TyCtxt<'_>, encoder: &mut Encoder) {
time(tcx.sess, "serialize query result cache", || {
let _timer = tcx.prof.generic_activity("incr_comp_serialize_result_cache");
tcx.serialize_query_result_cache(encoder).unwrap();
})
}

View file

@ -250,6 +250,8 @@ pub fn register_plugins<'a>(
if sess.opts.incremental.is_some() {
time(sess, "garbage-collect incremental cache directory", || {
let _prof_timer =
sess.prof.generic_activity("incr_comp_garbage_collect_session_directories");
if let Err(e) = rustc_incremental::garbage_collect_session_directories(sess) {
warn!(
"Error while trying to garbage collect incremental \

View file

@ -285,7 +285,11 @@ pub fn collect_crate_mono_items(
tcx: TyCtxt<'_>,
mode: MonoItemCollectionMode,
) -> (FxHashSet<MonoItem<'_>>, InliningMap<'_>) {
let _prof_timer = tcx.prof.generic_activity("monomorphization_collector");
let roots = time(tcx.sess, "collecting roots", || {
let _prof_timer = tcx.prof
.generic_activity("monomorphization_collector_root_collections");
collect_roots(tcx, mode)
});
@ -295,6 +299,9 @@ pub fn collect_crate_mono_items(
let mut inlining_map = MTLock::new(InliningMap::new());
{
let _prof_timer = tcx.prof
.generic_activity("monomorphization_collector_graph_walk");
let visited: MTRef<'_, _> = &mut visited;
let inlining_map: MTRef<'_, _> = &mut inlining_map;

View file

@ -134,10 +134,15 @@ pub fn partition<'tcx, I>(
where
I: Iterator<Item = MonoItem<'tcx>>,
{
let _prof_timer = tcx.prof.generic_activity("cgu_partitioning");
// In the first step, we place all regular monomorphizations into their
// respective 'home' codegen unit. Regular monomorphizations are all
// functions and statics defined in the local crate.
let mut initial_partitioning = place_root_mono_items(tcx, mono_items);
let mut initial_partitioning = {
let _prof_timer = tcx.prof.generic_activity("cgu_partitioning_place_roots");
place_root_mono_items(tcx, mono_items)
};
initial_partitioning.codegen_units.iter_mut().for_each(|cgu| cgu.estimate_size(tcx));
@ -146,8 +151,8 @@ where
// If the partitioning should produce a fixed count of codegen units, merge
// until that count is reached.
if let PartitioningStrategy::FixedUnitCount(count) = strategy {
let _prof_timer = tcx.prof.generic_activity("cgu_partitioning_merge_cgus");
merge_codegen_units(tcx, &mut initial_partitioning, count);
debug_dump(tcx, "POST MERGING:", initial_partitioning.codegen_units.iter());
}
@ -155,8 +160,11 @@ where
// monomorphizations have to go into each codegen unit. These additional
// monomorphizations can be drop-glue, functions from external crates, and
// local functions the definition of which is marked with `#[inline]`.
let mut post_inlining = place_inlined_mono_items(initial_partitioning,
inlining_map);
let mut post_inlining = {
let _prof_timer =
tcx.prof.generic_activity("cgu_partitioning_place_inline_items");
place_inlined_mono_items(initial_partitioning, inlining_map)
};
post_inlining.codegen_units.iter_mut().for_each(|cgu| cgu.estimate_size(tcx));
@ -165,6 +173,8 @@ where
// Next we try to make as many symbols "internal" as possible, so LLVM has
// more freedom to optimize.
if !tcx.sess.opts.cg.link_dead_code {
let _prof_timer =
tcx.prof.generic_activity("cgu_partitioning_internalize_symbols");
internalize_symbols(tcx, &mut post_inlining, inlining_map);
}

View file

@ -1255,6 +1255,9 @@ impl<'a> Resolver<'a> {
/// Entry point to crate resolution.
pub fn resolve_crate(&mut self, krate: &Crate) {
let _prof_timer =
self.session.prof.generic_activity("resolve_crate");
ImportResolver { r: self }.finalize_imports();
self.finalize_macro_resolutions();