From 81dccb1a5c7b67c61cb7eb421150c671d6e1a7de Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Fri, 7 Feb 2020 15:01:23 +0100 Subject: self-profile: Support arguments for generic_activities. --- src/librustc_codegen_ssa/back/link.rs | 2 +- src/librustc_codegen_ssa/back/write.rs | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) (limited to 'src/librustc_codegen_ssa') diff --git a/src/librustc_codegen_ssa/back/link.rs b/src/librustc_codegen_ssa/back/link.rs index 4f05aac0898..d3b8f7ea33f 100644 --- a/src/librustc_codegen_ssa/back/link.rs +++ b/src/librustc_codegen_ssa/back/link.rs @@ -1648,7 +1648,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.extra_verbose_generic_activity(&format!("altering {}.rlib", name)).run(|| { + sess.prof.generic_activity_with_arg("link_altering_rlib", name).run(|| { let mut archive = ::new(sess, &dst, Some(cratepath)); archive.update_symbols(); diff --git a/src/librustc_codegen_ssa/back/write.rs b/src/librustc_codegen_ssa/back/write.rs index 841827d15fe..9905b3a56c0 100644 --- a/src/librustc_codegen_ssa/back/write.rs +++ b/src/librustc_codegen_ssa/back/write.rs @@ -21,6 +21,7 @@ use rustc::session::Session; use rustc::ty::TyCtxt; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::profiling::SelfProfilerRef; +use rustc_data_structures::profiling::TimingGuard; use rustc_data_structures::profiling::VerboseTimingGuard; use rustc_data_structures::svh::Svh; use rustc_data_structures::sync::Lrc; @@ -691,11 +692,17 @@ impl WorkItem { } } - fn profiling_event_id(&self) -> &'static str { + fn start_profiling<'a>(&self, cgcx: &'a CodegenContext) -> TimingGuard<'a> { match *self { - WorkItem::Optimize(_) => "codegen_module_optimize", - WorkItem::CopyPostLtoArtifacts(_) => "codegen_copy_artifacts_from_incr_cache", - WorkItem::LTO(_) => "codegen_module_perform_lto", + WorkItem::Optimize(ref m) => { + cgcx.prof.generic_activity_with_arg("codegen_module_optimize", &m.name[..]) + } + WorkItem::CopyPostLtoArtifacts(ref m) => cgcx + .prof + .generic_activity_with_arg("codegen_copy_artifacts_from_incr_cache", &m.name[..]), + WorkItem::LTO(ref m) => { + cgcx.prof.generic_activity_with_arg("codegen_module_perform_lto", m.name()) + } } } } @@ -1520,7 +1527,7 @@ fn start_executing_work( llvm_start_time: &mut Option>, ) { if config.time_module && llvm_start_time.is_none() { - *llvm_start_time = Some(prof.extra_verbose_generic_activity("LLVM_passes")); + *llvm_start_time = Some(prof.extra_verbose_generic_activity("LLVM_passes", "crate")); } } } @@ -1575,7 +1582,7 @@ fn spawn_work(cgcx: CodegenContext, work: WorkItem // as a diagnostic was already sent off to the main thread - just // surface that there was an error in this worker. bomb.result = { - let _prof_timer = cgcx.prof.generic_activity(work.profiling_event_id()); + let _prof_timer = work.start_profiling(&cgcx); Some(execute_work_item(&cgcx, work)) }; }); -- cgit 1.4.1-3-g733a5