self-profiling: Add events for everything except trait selection.
This commit is contained in:
parent
275cf4bcac
commit
ceb1a9cfe3
9 changed files with 39 additions and 4 deletions
|
@ -845,6 +845,8 @@ impl DepGraph {
|
||||||
// This method will only load queries that will end up in the disk cache.
|
// This method will only load queries that will end up in the disk cache.
|
||||||
// Other queries will not be executed.
|
// Other queries will not be executed.
|
||||||
pub fn exec_cache_promotions(&self, tcx: TyCtxt<'_>) {
|
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();
|
let data = self.data.as_ref().unwrap();
|
||||||
for prev_index in data.colors.values.indices() {
|
for prev_index in data.colors.values.indices() {
|
||||||
match data.colors.get(prev_index) {
|
match data.colors.get(prev_index) {
|
||||||
|
|
|
@ -242,6 +242,8 @@ pub fn lower_crate(
|
||||||
// incr. comp. yet.
|
// incr. comp. yet.
|
||||||
dep_graph.assert_ignored();
|
dep_graph.assert_ignored();
|
||||||
|
|
||||||
|
let _prof_timer = sess.prof.generic_activity("hir_lowering");
|
||||||
|
|
||||||
LoweringContext {
|
LoweringContext {
|
||||||
crate_root: sess.parse_sess.injected_crate_name.try_get().copied(),
|
crate_root: sess.parse_sess.injected_crate_name.try_get().copied(),
|
||||||
sess,
|
sess,
|
||||||
|
|
|
@ -1222,6 +1222,8 @@ pub fn map_crate<'hir>(sess: &crate::session::Session,
|
||||||
forest: &'hir Forest,
|
forest: &'hir Forest,
|
||||||
definitions: &'hir Definitions)
|
definitions: &'hir Definitions)
|
||||||
-> Map<'hir> {
|
-> Map<'hir> {
|
||||||
|
let _prof_timer = sess.prof.generic_activity("build_hir_map");
|
||||||
|
|
||||||
// Build the reverse mapping of `node_to_hir_id`.
|
// Build the reverse mapping of `node_to_hir_id`.
|
||||||
let hir_to_node_id = definitions.node_to_hir_id.iter_enumerated()
|
let hir_to_node_id = definitions.node_to_hir_id.iter_enumerated()
|
||||||
.map(|(node_id, &hir_id)| (hir_id, node_id)).collect();
|
.map(|(node_id, &hir_id)| (hir_id, node_id)).collect();
|
||||||
|
|
|
@ -101,6 +101,7 @@ pub fn load_dep_graph(sess: &Session) -> DepGraphFuture {
|
||||||
// before we fire the background thread.
|
// before we fire the background thread.
|
||||||
|
|
||||||
let time_passes = sess.time_passes();
|
let time_passes = sess.time_passes();
|
||||||
|
let prof = sess.prof.clone();
|
||||||
|
|
||||||
if sess.opts.incremental.is_none() {
|
if sess.opts.incremental.is_none() {
|
||||||
// No incremental compilation.
|
// No incremental compilation.
|
||||||
|
@ -161,6 +162,8 @@ pub fn load_dep_graph(sess: &Session) -> DepGraphFuture {
|
||||||
|
|
||||||
MaybeAsync::Async(std::thread::spawn(move || {
|
MaybeAsync::Async(std::thread::spawn(move || {
|
||||||
time_ext(time_passes, "background load prev dep-graph", 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) {
|
match load_data(report_incremental_info, &path) {
|
||||||
LoadResult::DataOutOfDate => LoadResult::DataOutOfDate,
|
LoadResult::DataOutOfDate => LoadResult::DataOutOfDate,
|
||||||
LoadResult::Error { message } => LoadResult::Error { message },
|
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());
|
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)) {
|
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),
|
LoadResult::Ok{ data: (bytes, start_pos) } => OnDiskCache::new(sess, bytes, start_pos),
|
||||||
_ => OnDiskCache::new_empty(sess.source_map())
|
_ => OnDiskCache::new_empty(sess.source_map())
|
||||||
|
|
|
@ -241,6 +241,8 @@ fn encode_work_product_index(work_products: &FxHashMap<WorkProductId, WorkProduc
|
||||||
|
|
||||||
fn encode_query_cache(tcx: TyCtxt<'_>, encoder: &mut Encoder) {
|
fn encode_query_cache(tcx: TyCtxt<'_>, encoder: &mut Encoder) {
|
||||||
time(tcx.sess, "serialize query result cache", || {
|
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();
|
tcx.serialize_query_result_cache(encoder).unwrap();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -250,6 +250,8 @@ pub fn register_plugins<'a>(
|
||||||
|
|
||||||
if sess.opts.incremental.is_some() {
|
if sess.opts.incremental.is_some() {
|
||||||
time(sess, "garbage-collect incremental cache directory", || {
|
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) {
|
if let Err(e) = rustc_incremental::garbage_collect_session_directories(sess) {
|
||||||
warn!(
|
warn!(
|
||||||
"Error while trying to garbage collect incremental \
|
"Error while trying to garbage collect incremental \
|
||||||
|
|
|
@ -285,7 +285,11 @@ pub fn collect_crate_mono_items(
|
||||||
tcx: TyCtxt<'_>,
|
tcx: TyCtxt<'_>,
|
||||||
mode: MonoItemCollectionMode,
|
mode: MonoItemCollectionMode,
|
||||||
) -> (FxHashSet<MonoItem<'_>>, InliningMap<'_>) {
|
) -> (FxHashSet<MonoItem<'_>>, InliningMap<'_>) {
|
||||||
|
let _prof_timer = tcx.prof.generic_activity("monomorphization_collector");
|
||||||
|
|
||||||
let roots = time(tcx.sess, "collecting roots", || {
|
let roots = time(tcx.sess, "collecting roots", || {
|
||||||
|
let _prof_timer = tcx.prof
|
||||||
|
.generic_activity("monomorphization_collector_root_collections");
|
||||||
collect_roots(tcx, mode)
|
collect_roots(tcx, mode)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -295,6 +299,9 @@ pub fn collect_crate_mono_items(
|
||||||
let mut inlining_map = MTLock::new(InliningMap::new());
|
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 visited: MTRef<'_, _> = &mut visited;
|
||||||
let inlining_map: MTRef<'_, _> = &mut inlining_map;
|
let inlining_map: MTRef<'_, _> = &mut inlining_map;
|
||||||
|
|
||||||
|
|
|
@ -134,10 +134,15 @@ pub fn partition<'tcx, I>(
|
||||||
where
|
where
|
||||||
I: Iterator<Item = MonoItem<'tcx>>,
|
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
|
// In the first step, we place all regular monomorphizations into their
|
||||||
// respective 'home' codegen unit. Regular monomorphizations are all
|
// respective 'home' codegen unit. Regular monomorphizations are all
|
||||||
// functions and statics defined in the local crate.
|
// 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));
|
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
|
// If the partitioning should produce a fixed count of codegen units, merge
|
||||||
// until that count is reached.
|
// until that count is reached.
|
||||||
if let PartitioningStrategy::FixedUnitCount(count) = strategy {
|
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);
|
merge_codegen_units(tcx, &mut initial_partitioning, count);
|
||||||
|
|
||||||
debug_dump(tcx, "POST MERGING:", initial_partitioning.codegen_units.iter());
|
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 have to go into each codegen unit. These additional
|
||||||
// monomorphizations can be drop-glue, functions from external crates, and
|
// monomorphizations can be drop-glue, functions from external crates, and
|
||||||
// local functions the definition of which is marked with `#[inline]`.
|
// local functions the definition of which is marked with `#[inline]`.
|
||||||
let mut post_inlining = place_inlined_mono_items(initial_partitioning,
|
let mut post_inlining = {
|
||||||
inlining_map);
|
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));
|
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
|
// Next we try to make as many symbols "internal" as possible, so LLVM has
|
||||||
// more freedom to optimize.
|
// more freedom to optimize.
|
||||||
if !tcx.sess.opts.cg.link_dead_code {
|
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);
|
internalize_symbols(tcx, &mut post_inlining, inlining_map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1255,6 +1255,9 @@ impl<'a> Resolver<'a> {
|
||||||
|
|
||||||
/// Entry point to crate resolution.
|
/// Entry point to crate resolution.
|
||||||
pub fn resolve_crate(&mut self, krate: &Crate) {
|
pub fn resolve_crate(&mut self, krate: &Crate) {
|
||||||
|
let _prof_timer =
|
||||||
|
self.session.prof.generic_activity("resolve_crate");
|
||||||
|
|
||||||
ImportResolver { r: self }.finalize_imports();
|
ImportResolver { r: self }.finalize_imports();
|
||||||
self.finalize_macro_resolutions();
|
self.finalize_macro_resolutions();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue