Skip to content
Permalink
Browse files

Change -Z time event naming scheme and make them generic activities

  • Loading branch information
Zoxc committed Jan 7, 2020
1 parent adc6572 commit 5427601e9ed173ad8e36adf02e5883729753af20
@@ -1270,7 +1270,7 @@ pub fn map_crate<'hir>(
definitions,
};

sess.time("validate HIR map", || {
sess.time("validate_HIR_map", || {
hir_id_validator::check_crate(&map);
});

@@ -198,7 +198,7 @@ impl<'sess> OnDiskCache<'sess> {
// Encode query results.
let mut query_result_index = EncodedQueryResultIndex::new();

tcx.sess.time("encode query results", || {
tcx.sess.time("encode_query_results", || {
let enc = &mut encoder;
let qri = &mut query_result_index;

@@ -1053,8 +1053,8 @@ where
Q: super::config::QueryDescription<'tcx, Value: Encodable>,
E: 'a + TyEncoder,
{
let desc = &format!("encode_query_results for {}", ::std::any::type_name::<Q>());
let _timer = tcx.sess.prof.generic_pass(desc);
let desc = &format!("encode_query_results_for_{}", ::std::any::type_name::<Q>());
let _timer = tcx.sess.prof.extra_verbose_generic_activity(desc);

let shards = Q::query_cache(tcx).lock_shards();
assert!(shards.iter().all(|shard| shard.active.is_empty()));
@@ -120,12 +120,13 @@ fn prepare_lto(
info!("adding bytecode {}", name);
let bc_encoded = data.data();

let (bc, id) = cgcx.prof.generic_pass(&format!("decode {}", name)).run(|| {
match DecodedBytecode::new(bc_encoded) {
let (bc, id) = cgcx
.prof
.extra_verbose_generic_activity(&format!("decode {}", name))
.run(|| match DecodedBytecode::new(bc_encoded) {
Ok(b) => Ok((b.bytecode(), b.identifier().to_string())),
Err(e) => Err(diag_handler.fatal(&e)),
}
})?;
})?;
let bc = SerializedModule::FromRlib(bc);
upstream_modules.push((bc, CString::new(id).unwrap()));
}
@@ -280,8 +281,9 @@ fn fat_lto(
// save and persist everything with the original module.
let mut linker = Linker::new(llmod);
for (bc_decoded, name) in serialized_modules {
let _timer = cgcx.prof.generic_activity("LLVM_fat_lto_link_module");
info!("linking {:?}", name);
cgcx.prof.generic_pass(&format!("ll link {:?}", name)).run(|| {
cgcx.prof.extra_verbose_generic_activity(&format!("ll link {:?}", name)).run(|| {
let data = bc_decoded.data();
linker.add(&data).map_err(|()| {
let msg = format!("failed to load bc of {:?}", name);
@@ -633,7 +635,7 @@ pub(crate) fn run_pass_manager(
}

cgcx.prof
.generic_pass("LTO passes")
.extra_verbose_generic_activity("LTO_passes")
.run(|| llvm::LLVMRunPassManager(pm, module.module_llvm.llmod()));

llvm::LLVMDisposePassManager(pm);
@@ -424,13 +424,23 @@ pub(crate) unsafe fn optimize(

// Finally, run the actual optimization passes
{
let _timer = cgcx.prof.generic_activity("LLVM_module_optimize_function_passes");
let desc = &format!("llvm function passes [{}]", module_name.unwrap());
let _timer = if config.time_module { Some(cgcx.prof.generic_pass(desc)) } else { None };
let _timer = if config.time_module {
Some(cgcx.prof.extra_verbose_generic_activity(desc))
} else {
None
};
llvm::LLVMRustRunFunctionPassManager(fpm, llmod);
}
{
let _timer = cgcx.prof.generic_activity("LLVM_module_optimize_module_passes");
let desc = &format!("llvm module passes [{}]", module_name.unwrap());
let _timer = if config.time_module { Some(cgcx.prof.generic_pass(desc)) } else { None };
let _timer = if config.time_module {
Some(cgcx.prof.extra_verbose_generic_activity(desc))
} else {
None
};
llvm::LLVMRunPassManager(mpm, llmod);
}

@@ -556,7 +566,11 @@ pub(crate) unsafe fn codegen(

{
let desc = &format!("codegen passes [{}]", module_name.unwrap());
let _timer = if config.time_module { Some(cgcx.prof.generic_pass(desc)) } else { None };
let _timer = if config.time_module {
Some(cgcx.prof.extra_verbose_generic_activity(desc))
} else {
None
};

if config.emit_ir {
let _timer = cgcx.prof.generic_activity("LLVM_module_codegen_emit_ir");
@@ -283,7 +283,7 @@ impl CodegenBackend for LlvmCodegenBackend {
rustc_codegen_ssa::back::write::dump_incremental_data(&codegen_results);
}

sess.time("serialize work products", move || {
sess.time("serialize_work_products", move || {
rustc_incremental::save_work_product_index(sess, &dep_graph, work_products)
});

@@ -300,7 +300,7 @@ impl CodegenBackend for LlvmCodegenBackend {

// Run the linker on any artifacts that resulted from the LLVM run.
// This should produce either a finished executable or library.
sess.time("linking", || {
sess.time("link_crate", || {
use crate::back::archive::LlvmArchiveBuilder;
use rustc_codegen_ssa::back::link::link_binary;

@@ -577,7 +577,7 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
let mut i = 0;
loop {
i += 1;
prog = sess.time("running linker", || exec_linker(sess, &mut cmd, out_filename, tmpdir));
prog = sess.time("run_linker", || exec_linker(sess, &mut cmd, out_filename, tmpdir));
let output = match prog {
Ok(ref output) => output,
Err(_) => break,
@@ -1562,7 +1562,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
let name = cratepath.file_name().unwrap().to_str().unwrap();
let name = &name[3..name.len() - 5]; // chop off lib/.rlib

sess.prof.generic_pass(&format!("altering {}.rlib", name)).run(|| {
sess.prof.extra_verbose_generic_activity(&format!("altering {}.rlib", name)).run(|| {
let mut archive = <B as ArchiveBuilder>::new(sess, &dst, Some(cratepath));
archive.update_symbols();

@@ -1511,7 +1511,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
llvm_start_time: &mut Option<VerboseTimingGuard<'a>>,
) {
if config.time_module && llvm_start_time.is_none() {
*llvm_start_time = Some(prof.generic_pass("LLVM passes"));
*llvm_start_time = Some(prof.extra_verbose_generic_activity("LLVM_passes"));
}
}
}
@@ -566,7 +566,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
cgu_name_builder.build_cgu_name(LOCAL_CRATE, &["crate"], Some("allocator")).to_string();
let mut modules = backend.new_metadata(tcx, &llmod_id);
tcx.sess
.time("write allocator module", || backend.codegen_allocator(tcx, &mut modules, kind));
.time("write_allocator_module", || backend.codegen_allocator(tcx, &mut modules, kind));

Some(ModuleCodegen { name: llmod_id, module_llvm: modules, kind: ModuleKind::Allocator })
} else {
@@ -582,7 +582,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
let metadata_cgu_name =
cgu_name_builder.build_cgu_name(LOCAL_CRATE, &["crate"], Some("metadata")).to_string();
let mut metadata_llvm_module = backend.new_metadata(tcx, &metadata_cgu_name);
tcx.sess.time("write compressed metadata", || {
tcx.sess.time("write_compressed_metadata", || {
backend.write_compressed_metadata(
tcx,
&ongoing_codegen.metadata,
@@ -652,7 +652,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(

// Since the main thread is sometimes blocked during codegen, we keep track
// -Ztime-passes output manually.
print_time_passes_entry(tcx.sess.time_passes(), "codegen to LLVM IR", total_codegen_time);
print_time_passes_entry(tcx.sess.time_passes(), "codegen_to_LLVM_IR", total_codegen_time);

::rustc_incremental::assert_module_sources::assert_module_sources(tcx);

@@ -712,9 +712,9 @@ impl<B: ExtraBackendMethods> Drop for AbortCodegenOnDrop<B> {
}

fn assert_and_save_dep_graph(tcx: TyCtxt<'_>) {
tcx.sess.time("assert dep graph", || ::rustc_incremental::assert_dep_graph(tcx));
tcx.sess.time("assert_dep_graph", || ::rustc_incremental::assert_dep_graph(tcx));

tcx.sess.time("serialize dep graph", || ::rustc_incremental::save_dep_graph(tcx));
tcx.sess.time("serialize_dep_graph", || ::rustc_incremental::save_dep_graph(tcx));
}

impl CrateInfo {

0 comments on commit 5427601

Please sign in to comment.
You can’t perform that action at this time.