rust/compiler
Guillaume Gomez 6ac5c28412
Rollup merge of #144727 - Stypox:add-tracing-to-resolve, r=RalfJung
Add tracing to resolve-related functions

Resolve-related functions are not called often but still make up for ~3% of execution time for non-repetitive programs (as seen in the first table below, obtained from running the rust snippet at the bottom with `n=1`). On the other hand, for repetitive programs they become less relevant (I tested the same snippet but with `n=100` and got ~1.5%), and it appears that only `try_resolve` is called more often (see the last two tables).

The first table was obtained by opening the trace file in https://ui.perfetto.dev and running the following query:

```sql
select "TOTAL PROGRAM DURATION" as name, count(*), max(ts + dur) as "sum(dur)", 100.0 as "%", null as "min(dur)", null as "max(dur)", null as "avg(dur)", null as "stddev(dur)" from slices union select "TOTAL OVER ALL SPANS (excluding events)" as name, count(*), sum(dur), cast(cast(sum(dur) as float) / (select max(ts + dur) from slices) * 1000 as int) / 10.0 as "%", min(dur), max(dur), cast(avg(dur) as int) as "avg(dur)", cast(sqrt(avg(dur*dur)-avg(dur)*avg(dur)) as int) as "stddev(dur)" from slices where parent_id is null and name != "frame" and name != "step" and dur > 0 union select name, count(*), sum(dur), cast(cast(sum(dur) as float) / (select max(ts + dur) from slices) * 1000 as int) / 10.0 as "%", min(dur), max(dur), cast(avg(dur) as int) as "avg(dur)", cast(sqrt(avg(dur*dur)-avg(dur)*avg(dur)) as int) as "stddev(dur)" from slices where parent_id is null and name != "frame" and name != "step" group by name order by sum(dur) desc, count(*) desc
```

<img width="1687" height="242" alt="image" src="https://github.com/user-attachments/assets/4d4bd890-869b-40f3-a473-8e4c42b02da4" />

The following two tables show how many `resolve` spans there per subname/subcategory, and how much time is spent in each. The first is for `n=1` and the second for `n=100`. The query that was used is:

```sql
select args.string_value as name, count(*), max(dur), avg(dur), sum(dur) from slices inner join args USING (arg_set_id) where args.key = "args." || slices.name and name = "resolve" group by args.string_value
```

<img width="1688" height="159" alt="image" src="https://github.com/user-attachments/assets/a8749856-c099-492e-a86e-6d67b146af9c" />

<img width="1688" height="159" alt="image" src="https://github.com/user-attachments/assets/ce3ac1b5-5c06-47d9-85a6-9b921aea348e" />

The snippet I tested with Miri to obtain the above traces is:

```rust
fn main() {
    let n: usize = std::env::args().nth(1).unwrap().parse().unwrap();
    let mut v = (0..n).into_iter().collect::<Vec<_>>();
    for i in &mut v {
        *i += 1;
    }
}
```
2025-08-14 11:39:35 +02:00
..
rustc rename stable_mir to rustc_public, and rustc_smir to rustc_public_bridge 2025-07-14 09:25:54 +00:00
rustc_abi Reuse sign_extend helper 2025-07-29 14:17:48 +00:00
rustc_arena Introduce Arena::try_alloc_from_iter. 2025-04-19 01:13:18 +00:00
rustc_ast Extract ast TraitImplHeader 2025-08-11 17:05:36 -05:00
rustc_ast_ir Tidy up Cargo.toml files. 2025-07-31 19:58:04 +10:00
rustc_ast_lowering Rollup merge of #145153 - joshtriplett:macro-kinds-plural, r=petrochenkov 2025-08-13 18:43:01 +02:00
rustc_ast_passes Extract ast TraitImplHeader 2025-08-11 17:05:36 -05:00
rustc_ast_pretty Extract ast TraitImplHeader 2025-08-11 17:05:36 -05:00
rustc_attr_parsing Rollup merge of #145238 - estebank:attr-overhaul, r=jdonszelmann 2025-08-12 20:37:53 +10:00
rustc_baked_icu_data Add unreachable_pub to RUSTC_LINT_FLAGS for compiler/ crates. 2025-03-11 13:14:21 +11:00
rustc_borrowck Rollup merge of #145111 - fee1-dead-contrib:push-rlvnyrztlkpq, r=jieyouxu 2025-08-11 16:19:05 +02:00
rustc_builtin_macros Rollup merge of #145238 - estebank:attr-overhaul, r=jdonszelmann 2025-08-12 20:37:53 +10:00
rustc_codegen_cranelift Rollup merge of #144192 - RalfJung:atomicrmw-ptr, r=nikic 2025-08-08 14:22:44 -05:00
rustc_codegen_gcc Rollup merge of #144192 - RalfJung:atomicrmw-ptr, r=nikic 2025-08-08 14:22:44 -05:00
rustc_codegen_llvm Rollup merge of #145241 - tomtor:avr-layout, r=nikic 2025-08-13 18:43:02 +02:00
rustc_codegen_ssa Auto merge of #144678 - jdonszelmann:no-mangle-extern, r=bjorn3 2025-08-12 16:20:24 +00:00
rustc_const_eval Rollup merge of #144727 - Stypox:add-tracing-to-resolve, r=RalfJung 2025-08-14 11:39:35 +02:00
rustc_data_structures Allow pretty printing paths with -Zself-profile-events=args 2025-07-25 22:24:21 +02:00
rustc_driver Remove recursion_limit increases. 2025-04-02 16:25:27 +11:00
rustc_driver_impl Tidy up Cargo.toml files. 2025-07-31 19:58:04 +10:00
rustc_error_codes resolve: Split extern prelude into two scopes 2025-08-13 17:45:40 +03:00
rustc_error_messages Remove unused feature gates 2025-06-28 23:36:46 +00:00
rustc_errors Rollup merge of #144558 - estebank:issue-68119, r=lcnr 2025-08-11 12:21:08 +10:00
rustc_expand Rollup merge of #145153 - joshtriplett:macro-kinds-plural, r=petrochenkov 2025-08-13 18:43:01 +02:00
rustc_feature Rework NameValueStr 2025-08-11 17:02:43 +00:00
rustc_fluent_macro Remove all unused feature gates from the compiler 2025-06-08 14:50:42 +00:00
rustc_fs_util Retry if creating temp fails with access denied 2025-04-25 11:28:36 +00:00
rustc_graphviz Remove #![warn(unreachable_pub)] from all compiler/ crates. 2025-03-11 13:14:21 +11:00
rustc_hashes Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_hir Rollup merge of #145153 - joshtriplett:macro-kinds-plural, r=petrochenkov 2025-08-13 18:43:01 +02:00
rustc_hir_analysis Propagate TraitImplHeader to hir 2025-08-11 17:05:42 -05:00
rustc_hir_pretty Propagate TraitImplHeader to hir 2025-08-11 17:05:42 -05:00
rustc_hir_typeck Rollup merge of #144386 - camsteffen:imploftrait, r=fmease 2025-08-12 20:37:49 +10:00
rustc_incremental Auto merge of #139758 - Zoxc:thread-local-graph, r=oli-obk 2025-05-07 12:39:54 +00:00
rustc_index Tidy up Cargo.toml files. 2025-07-31 19:58:04 +10:00
rustc_index_macros Tidy up Cargo.toml files. 2025-07-31 19:58:04 +10:00
rustc_infer remove from_forall 2025-08-11 09:18:46 +02:00
rustc_interface Fix parallel rustc not being reproducible due to unstable sorting of items. 2025-08-13 08:59:32 +08:00
rustc_lexer test(lexer): Add frontmatter unit test 2025-07-10 10:25:29 -05:00
rustc_lint Rollup merge of #145153 - joshtriplett:macro-kinds-plural, r=petrochenkov 2025-08-13 18:43:01 +02:00
rustc_lint_defs Rollup merge of #145274 - compiler-errors:unused-must-use, r=fmease 2025-08-13 07:03:49 +02:00
rustc_llvm Auto merge of #145093 - nikic:dead-on-return, r=nnethercote 2025-08-13 04:18:43 +00:00
rustc_log Add documentation for init_logger_with_additional_layer 2025-06-12 12:11:15 +02:00
rustc_macros remove rustc_attr_data_structures 2025-07-31 14:19:27 +02:00
rustc_metadata Switch to a bitflags MacroKinds to support macros with more than one kind 2025-08-12 09:24:45 -07:00
rustc_middle Rollup merge of #144949 - nnethercote:more-Printer-cleanups, r=davidtwco 2025-08-13 18:42:59 +02:00
rustc_mir_build Auto merge of #143376 - dianne:guard-scope, r=matthewjasper 2025-08-09 03:19:26 +00:00
rustc_mir_dataflow Escape diff strings in graphviz 2025-08-08 00:20:55 -05:00
rustc_mir_transform make no_mangle explicit on foreign items 2025-08-12 12:07:14 +02:00
rustc_monomorphize Add support for shortening Instance and use it 2025-08-06 22:21:49 +00:00
rustc_next_trait_solver significantly improve provisional cache rebasing 2025-08-11 15:51:03 +02:00
rustc_parse Rollup merge of #145238 - estebank:attr-overhaul, r=jdonszelmann 2025-08-12 20:37:53 +10:00
rustc_parse_format update to literal-escaper-0.0.5 2025-07-08 10:16:44 +00:00
rustc_passes Rollup merge of #145274 - compiler-errors:unused-must-use, r=fmease 2025-08-13 07:03:49 +02:00
rustc_pattern_analysis Rollup merge of #144545 - ChayimFriedman2:bool-witness-order, r=Nadrieril 2025-08-08 14:22:44 -05:00
rustc_privacy Propagate TraitImplHeader to hir 2025-08-11 17:05:42 -05:00
rustc_proc_macro Tidy up Cargo.toml files. 2025-07-31 19:58:04 +10:00
rustc_public fix missing parenthesis in pretty discriminant 2025-08-09 01:35:50 +08:00
rustc_public_bridge Remove useless lifetime parameter. 2025-07-23 23:54:37 +00:00
rustc_query_impl Remove unused allow attrs 2025-07-07 12:58:16 +00:00
rustc_query_system remove rustc_attr_data_structures 2025-07-31 14:19:27 +02:00
rustc_resolve Auto merge of #144793 - petrochenkov:extprel3, r=davidtwco 2025-08-13 22:52:17 +00:00
rustc_sanitizers rename TraitRef::from_method to from_assoc 2025-08-09 14:22:01 +08:00
rustc_serialize use div_ceil instead of manual logic 2025-07-05 10:55:42 +02:00
rustc_session Fix parallel rustc not being reproducible due to unstable sorting of items. 2025-08-13 08:59:32 +08:00
rustc_span Rollup merge of #145132 - camsteffen:refactor-map-unit-fn, r=fee1-dead 2025-08-09 13:58:55 +10:00
rustc_symbol_mangling Rollup merge of #144949 - nnethercote:more-Printer-cleanups, r=davidtwco 2025-08-13 18:42:59 +02:00
rustc_target Rollup merge of #145241 - tomtor:avr-layout, r=nikic 2025-08-13 18:43:02 +02:00
rustc_thread_pool Drop rust-version from rustc_thread_pool 2025-08-04 15:03:49 -07:00
rustc_trait_selection Rollup merge of #144949 - nnethercote:more-Printer-cleanups, r=davidtwco 2025-08-13 18:42:59 +02:00
rustc_traits Auto merge of #144446 - nnethercote:opt-region-constraints, r=lcnr 2025-08-01 04:06:21 +00:00
rustc_transmute Tidy up Cargo.toml files. 2025-07-31 19:58:04 +10:00
rustc_ty_utils Propagate TraitImplHeader to hir 2025-08-11 17:05:42 -05:00
rustc_type_ir simplify stack handling, be completely lazy 2025-08-12 10:08:26 +02:00
rustc_type_ir_macros Split TypeFolder and FallibleTypeFolder 2025-04-15 18:30:35 +00:00