Skip to content

Commit 7b6553c

Browse files
authored
Rollup merge of rust-lang#146845 - Zalathar:prof-target-machine, r=Kobzol
Add self-profile events for target-machine creation These code paths are surprisingly hot in the `large-workspace` benchmark (e.g. see perf changes from rust-lang#146700), suggesting room for more improvement. It would be handy to see some detailed timings and execution counts.
2 parents 681da13 + b17fb70 commit 7b6553c

File tree

1 file changed

+10
-0
lines changed
  • compiler/rustc_codegen_llvm/src/back

1 file changed

+10
-0
lines changed

compiler/rustc_codegen_llvm/src/back/write.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ pub(crate) fn target_machine_factory(
204204
optlvl: config::OptLevel,
205205
target_features: &[String],
206206
) -> TargetMachineFactoryFn<LlvmCodegenBackend> {
207+
// Self-profile timer for creating a _factory_.
208+
let _prof_timer = sess.prof.generic_activity("target_machine_factory");
209+
207210
let reloc_model = to_llvm_relocation_model(sess.relocation_model());
208211

209212
let (opt_level, _) = to_llvm_opt_settings(optlvl);
@@ -259,6 +262,9 @@ pub(crate) fn target_machine_factory(
259262
.into_string()
260263
.unwrap_or_default();
261264
let command_line_args = quote_command_line_args(&sess.expanded_args);
265+
// Self-profile counter for the number of bytes produced by command-line quoting.
266+
// Values are summed, so the summary result is cumulative across all TM factories.
267+
sess.prof.artifact_size("quoted_command_line_args", "-", command_line_args.len() as u64);
262268

263269
let debuginfo_compression = sess.opts.debuginfo_compression.to_string();
264270
match sess.opts.debuginfo_compression {
@@ -281,7 +287,11 @@ pub(crate) fn target_machine_factory(
281287

282288
let use_wasm_eh = wants_wasm_eh(sess);
283289

290+
let prof = SelfProfilerRef::clone(&sess.prof);
284291
Arc::new(move |config: TargetMachineFactoryConfig| {
292+
// Self-profile timer for invoking a factory to create a target machine.
293+
let _prof_timer = prof.generic_activity("target_machine_factory_inner");
294+
285295
let path_to_cstring_helper = |path: Option<PathBuf>| -> CString {
286296
let path = path.unwrap_or_default();
287297
let path = path_mapping

0 commit comments

Comments
 (0)