Rollup merge of #68043 - Zoxc:missing-timers, r=wesleywiser
Add some missing timers Based on https://github.com/rust-lang/rust/pull/67988 r? @wesleywiser
This commit is contained in:
commit
8c0c5c7e65
@ -268,7 +268,7 @@ pub fn lower_crate<'a, 'hir>(
|
||||
// incr. comp. yet.
|
||||
dep_graph.assert_ignored();
|
||||
|
||||
let _prof_timer = sess.prof.generic_activity("hir_lowering");
|
||||
let _prof_timer = sess.prof.verbose_generic_activity("hir_lowering");
|
||||
|
||||
LoweringContext {
|
||||
crate_root: sess.parse_sess.injected_crate_name.try_get().copied(),
|
||||
|
@ -53,6 +53,7 @@ pub fn link_binary<'a, B: ArchiveBuilder<'a>>(
|
||||
crate_name: &str,
|
||||
target_cpu: &str,
|
||||
) {
|
||||
let _timer = sess.timer("link_binary");
|
||||
let output_metadata = sess.opts.output_types.contains_key(&OutputType::Metadata);
|
||||
for &crate_type in sess.crate_types.borrow().iter() {
|
||||
// Ignore executable crates if we have -Z no-codegen, as they will error.
|
||||
@ -71,9 +72,11 @@ pub fn link_binary<'a, B: ArchiveBuilder<'a>>(
|
||||
);
|
||||
}
|
||||
|
||||
for obj in codegen_results.modules.iter().filter_map(|m| m.object.as_ref()) {
|
||||
check_file_is_writeable(obj, sess);
|
||||
}
|
||||
sess.time("link_binary_check_files_are_writeable", || {
|
||||
for obj in codegen_results.modules.iter().filter_map(|m| m.object.as_ref()) {
|
||||
check_file_is_writeable(obj, sess);
|
||||
}
|
||||
});
|
||||
|
||||
let tmpdir = TempFileBuilder::new()
|
||||
.prefix("rustc")
|
||||
@ -84,6 +87,7 @@ pub fn link_binary<'a, B: ArchiveBuilder<'a>>(
|
||||
let out_filename = out_filename(sess, crate_type, outputs, crate_name);
|
||||
match crate_type {
|
||||
config::CrateType::Rlib => {
|
||||
let _timer = sess.timer("link_rlib");
|
||||
link_rlib::<B>(
|
||||
sess,
|
||||
codegen_results,
|
||||
@ -118,29 +122,34 @@ pub fn link_binary<'a, B: ArchiveBuilder<'a>>(
|
||||
}
|
||||
|
||||
// Remove the temporary object file and metadata if we aren't saving temps
|
||||
if !sess.opts.cg.save_temps {
|
||||
if sess.opts.output_types.should_codegen() && !preserve_objects_for_their_debuginfo(sess) {
|
||||
for obj in codegen_results.modules.iter().filter_map(|m| m.object.as_ref()) {
|
||||
sess.time("link_binary_remove_temps", || {
|
||||
if !sess.opts.cg.save_temps {
|
||||
if sess.opts.output_types.should_codegen()
|
||||
&& !preserve_objects_for_their_debuginfo(sess)
|
||||
{
|
||||
for obj in codegen_results.modules.iter().filter_map(|m| m.object.as_ref()) {
|
||||
remove(sess, obj);
|
||||
}
|
||||
}
|
||||
for obj in codegen_results.modules.iter().filter_map(|m| m.bytecode_compressed.as_ref())
|
||||
{
|
||||
remove(sess, obj);
|
||||
}
|
||||
}
|
||||
for obj in codegen_results.modules.iter().filter_map(|m| m.bytecode_compressed.as_ref()) {
|
||||
remove(sess, obj);
|
||||
}
|
||||
if let Some(ref metadata_module) = codegen_results.metadata_module {
|
||||
if let Some(ref obj) = metadata_module.object {
|
||||
remove(sess, obj);
|
||||
if let Some(ref metadata_module) = codegen_results.metadata_module {
|
||||
if let Some(ref obj) = metadata_module.object {
|
||||
remove(sess, obj);
|
||||
}
|
||||
}
|
||||
if let Some(ref allocator_module) = codegen_results.allocator_module {
|
||||
if let Some(ref obj) = allocator_module.object {
|
||||
remove(sess, obj);
|
||||
}
|
||||
if let Some(ref bc) = allocator_module.bytecode_compressed {
|
||||
remove(sess, bc);
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(ref allocator_module) = codegen_results.allocator_module {
|
||||
if let Some(ref obj) = allocator_module.object {
|
||||
remove(sess, obj);
|
||||
}
|
||||
if let Some(ref bc) = allocator_module.bytecode_compressed {
|
||||
remove(sess, bc);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// The third parameter is for env vars, used on windows to set up the
|
||||
|
@ -479,6 +479,8 @@ fn copy_all_cgu_workproducts_to_incr_comp_cache_dir(
|
||||
return work_products;
|
||||
}
|
||||
|
||||
let _timer = sess.timer("incr_comp_copy_cgu_workproducts");
|
||||
|
||||
for module in compiled_modules.modules.iter().filter(|m| m.kind == ModuleKind::Regular) {
|
||||
let mut files = vec![];
|
||||
|
||||
@ -1714,8 +1716,11 @@ pub struct OngoingCodegen<B: ExtraBackendMethods> {
|
||||
|
||||
impl<B: ExtraBackendMethods> OngoingCodegen<B> {
|
||||
pub fn join(self, sess: &Session) -> (CodegenResults, FxHashMap<WorkProductId, WorkProduct>) {
|
||||
let _timer = sess.timer("finish_ongoing_codegen");
|
||||
|
||||
self.shared_emitter_main.check(sess, true);
|
||||
let compiled_modules = match self.future.join() {
|
||||
let future = self.future;
|
||||
let compiled_modules = sess.time("join_worker_thread", || match future.join() {
|
||||
Ok(Ok(compiled_modules)) => compiled_modules,
|
||||
Ok(Err(())) => {
|
||||
sess.abort_if_errors();
|
||||
@ -1724,7 +1729,7 @@ impl<B: ExtraBackendMethods> OngoingCodegen<B> {
|
||||
Err(_) => {
|
||||
bug!("panic during codegen/LLVM phase");
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
sess.cgu_reuse_tracker.check_expected_reuse(sess.diagnostic());
|
||||
|
||||
|
@ -495,6 +495,12 @@ impl<'a> TimingGuard<'a> {
|
||||
pub fn none() -> TimingGuard<'a> {
|
||||
TimingGuard(None)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn run<R>(self, f: impl FnOnce() -> R) -> R {
|
||||
let _timer = self;
|
||||
f()
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
|
@ -389,6 +389,7 @@ pub fn run_compiler(
|
||||
})?;
|
||||
} else {
|
||||
// Drop AST after creating GlobalCtxt to free memory
|
||||
let _timer = sess.prof.generic_activity("drop_ast");
|
||||
mem::drop(queries.expansion()?.take());
|
||||
}
|
||||
|
||||
@ -413,6 +414,7 @@ pub fn run_compiler(
|
||||
})?;
|
||||
|
||||
if let Some(linker) = linker {
|
||||
let _timer = sess.timer("link");
|
||||
linker.link()?
|
||||
}
|
||||
|
||||
|
@ -190,6 +190,8 @@ pub fn prepare_session_directory(
|
||||
return;
|
||||
}
|
||||
|
||||
let _timer = sess.timer("incr_comp_prepare_session_directory");
|
||||
|
||||
debug!("prepare_session_directory");
|
||||
|
||||
// {incr-comp-dir}/{crate-name-and-disambiguator}
|
||||
@ -306,6 +308,8 @@ pub fn finalize_session_directory(sess: &Session, svh: Svh) {
|
||||
return;
|
||||
}
|
||||
|
||||
let _timer = sess.timer("incr_comp_finalize_session_directory");
|
||||
|
||||
let incr_comp_session_dir: PathBuf = sess.incr_comp_session_dir().clone();
|
||||
|
||||
if sess.has_errors_or_delayed_span_bugs() {
|
||||
|
@ -102,6 +102,8 @@ pub fn load_dep_graph(sess: &Session) -> DepGraphFuture {
|
||||
return MaybeAsync::Sync(LoadResult::Ok { data: Default::default() });
|
||||
}
|
||||
|
||||
let _timer = sess.prof.generic_activity("incr_comp_prepare_load_dep_graph");
|
||||
|
||||
// Calling `sess.incr_comp_session_dir()` will panic if `sess.opts.incremental.is_none()`.
|
||||
// Fortunately, we just checked that this isn't the case.
|
||||
let path = dep_graph_path_from(&sess.incr_comp_session_dir());
|
||||
|
@ -177,11 +177,17 @@ pub fn run_compiler_in_existing_thread_pool<R>(
|
||||
override_queries: config.override_queries,
|
||||
};
|
||||
|
||||
let _sess_abort_error = OnDrop(|| {
|
||||
compiler.sess.diagnostic().print_error_count(registry);
|
||||
});
|
||||
let r = {
|
||||
let _sess_abort_error = OnDrop(|| {
|
||||
compiler.sess.diagnostic().print_error_count(registry);
|
||||
});
|
||||
|
||||
f(&compiler)
|
||||
f(&compiler)
|
||||
};
|
||||
|
||||
let prof = compiler.sess.prof.clone();
|
||||
prof.generic_activity("drop_compiler").run(move || drop(compiler));
|
||||
r
|
||||
}
|
||||
|
||||
pub fn run_compiler<R: Send>(mut config: Config, f: impl FnOnce(&Compiler) -> R + Send) -> R {
|
||||
|
@ -610,6 +610,8 @@ pub fn prepare_outputs(
|
||||
boxed_resolver: &Steal<Rc<RefCell<BoxedResolver>>>,
|
||||
crate_name: &str,
|
||||
) -> Result<OutputFilenames> {
|
||||
let _timer = sess.timer("prepare_outputs");
|
||||
|
||||
// FIXME: rustdoc passes &[] instead of &krate.attrs here
|
||||
let outputs = util::build_output_filenames(
|
||||
&compiler.input,
|
||||
@ -733,20 +735,22 @@ pub fn create_global_ctxt<'tcx>(
|
||||
callback(sess, &mut local_providers, &mut extern_providers);
|
||||
}
|
||||
|
||||
let gcx = global_ctxt.init_locking(|| {
|
||||
TyCtxt::create_global_ctxt(
|
||||
sess,
|
||||
lint_store,
|
||||
local_providers,
|
||||
extern_providers,
|
||||
&all_arenas,
|
||||
arena,
|
||||
resolver_outputs,
|
||||
hir_map,
|
||||
query_result_on_disk_cache,
|
||||
&crate_name,
|
||||
&outputs,
|
||||
)
|
||||
let gcx = sess.time("setup_global_ctxt", || {
|
||||
global_ctxt.init_locking(|| {
|
||||
TyCtxt::create_global_ctxt(
|
||||
sess,
|
||||
lint_store,
|
||||
local_providers,
|
||||
extern_providers,
|
||||
&all_arenas,
|
||||
arena,
|
||||
resolver_outputs,
|
||||
hir_map,
|
||||
query_result_on_disk_cache,
|
||||
&crate_name,
|
||||
&outputs,
|
||||
)
|
||||
})
|
||||
});
|
||||
|
||||
// Do some initialization of the DepGraph that can only be done with the tcx available.
|
||||
|
@ -176,6 +176,7 @@ impl<'tcx> Queries<'tcx> {
|
||||
self.expansion.compute(|| {
|
||||
let crate_name = self.crate_name()?.peek().clone();
|
||||
let (krate, lint_store) = self.register_plugins()?.take();
|
||||
let _timer = self.session().timer("configure_and_expand");
|
||||
passes::configure_and_expand(
|
||||
self.session().clone(),
|
||||
lint_store.clone(),
|
||||
@ -256,6 +257,7 @@ impl<'tcx> Queries<'tcx> {
|
||||
let lint_store = self.expansion()?.peek().2.clone();
|
||||
let hir = self.lower_to_hir()?.peek();
|
||||
let (ref hir_forest, ref resolver_outputs) = &*hir;
|
||||
let _timer = self.session().timer("create_global_ctxt");
|
||||
Ok(passes::create_global_ctxt(
|
||||
self.compiler,
|
||||
lint_store,
|
||||
@ -312,14 +314,19 @@ pub struct Linker {
|
||||
|
||||
impl Linker {
|
||||
pub fn link(self) -> Result<()> {
|
||||
self.codegen_backend
|
||||
let r = self
|
||||
.codegen_backend
|
||||
.join_codegen_and_link(
|
||||
self.ongoing_codegen,
|
||||
&self.sess,
|
||||
&self.dep_graph,
|
||||
&self.prepare_outputs,
|
||||
)
|
||||
.map_err(|_| ErrorReported)
|
||||
.map_err(|_| ErrorReported);
|
||||
let prof = self.sess.prof.clone();
|
||||
let dep_graph = self.dep_graph;
|
||||
prof.generic_activity("drop_dep_graph").run(move || drop(dep_graph));
|
||||
r
|
||||
}
|
||||
}
|
||||
|
||||
@ -328,6 +335,7 @@ impl Compiler {
|
||||
where
|
||||
F: for<'tcx> FnOnce(&'tcx Queries<'tcx>) -> T,
|
||||
{
|
||||
let mut _timer = None;
|
||||
let queries = Queries::new(&self);
|
||||
let ret = f(&queries);
|
||||
|
||||
@ -337,6 +345,8 @@ impl Compiler {
|
||||
}
|
||||
}
|
||||
|
||||
_timer = Some(self.session().timer("free_global_ctxt"));
|
||||
|
||||
ret
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user