Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Jan 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/librustc/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down
6 changes: 3 additions & 3 deletions src/librustc/ty/query/on_disk_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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()));
Expand Down
14 changes: 8 additions & 6 deletions src/librustc_codegen_llvm/back/lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
20 changes: 17 additions & 3 deletions src/librustc_codegen_llvm/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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");
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_codegen_llvm/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
});

Expand All @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions src/librustc_codegen_ssa/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/librustc_codegen_ssa/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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 {
Expand Down
Loading