rust/compiler
bors 48cab67447 Auto merge of #77257 - ecstatic-morse:optimize-int-range-from-pat, r=Mark-Simulacrum
Optimize `IntRange::from_pat`, then shrink `ParamEnv`

Resolves #77058.

r? `@Mark-Simulacrum`
cc `@vandenheuvel`

Looking at the output of `perf report` for #76244, the hot instructions seemed to be around the call to `pat_constructor` in `IntRange::from_pat`. I carried out an obvious optimization, but it actually made the instruction count higher (see #77075). However, it seems to have mitigated whatever was causing the pipeline stalls, so when combined with #76244, it's a net win.

As you can see below, the regression in #76244 seems to have originated from something measured by `stalled-cycles-backend`. I'll try to collect some finer-grained stats to see if I can isolate it. I wish I had a better idea of what was going on here. I'd like to prevent the regression from reappearing in the future due to small changes in unrelated code.

<details>
<summary>Current `master`:</summary>

```
 Performance counter stats for 'cargo +baseline-stage1 check':

          2,275.67 msec task-clock:u              #    0.998 CPUs utilized
                 0      context-switches:u        #    0.000 K/sec
                 0      cpu-migrations:u          #    0.000 K/sec
            49,826      page-faults:u             #    0.022 M/sec
     5,117,221,678      cycles:u                  #    2.249 GHz
       299,655,943      stalled-cycles-frontend:u #    5.86% frontend cycles idle
     2,284,213,395      stalled-cycles-backend:u  #   44.64% backend cycles idle
     8,051,871,959      instructions:u            #    1.57  insn per cycle
                                                  #    0.28  stalled cycles per insn
     1,359,589,402      branches:u                #  597.447 M/sec
         7,359,347      branch-misses:u           #    0.54% of all branches

       2.281030026 seconds time elapsed

       2.108197000 seconds user
       0.164183000 seconds sys
```
</details>

<details>
<summary>Shrink `ParamEnv` without changing `IntRange::from_pat`:</summary>

```
 Performance counter stats for 'cargo +perf-stage1 check':

          2,751.79 msec task-clock:u              #    0.996 CPUs utilized
                 0      context-switches:u        #    0.000 K/sec
                 0      cpu-migrations:u          #    0.000 K/sec
            50,103      page-faults:u             #    0.018 M/sec
     6,260,590,019      cycles:u                  #    2.275 GHz
       317,355,920      stalled-cycles-frontend:u #    5.07% frontend cycles idle
     3,397,743,582      stalled-cycles-backend:u  #   54.27% backend cycles idle
     8,276,224,367      instructions:u            #    1.32  insn per cycle
                                                  #    0.41  stalled cycles per insn
     1,370,453,386      branches:u                #  498.023 M/sec
         7,281,031      branch-misses:u           #    0.53% of all branches

       2.763265838 seconds time elapsed

       2.544578000 seconds user
       0.204548000 seconds sys
```
</details>

<details>
<summary>Shrink `ParamEnv` and change `IntRange::from_pat`: </summary>

```
 Performance counter stats for 'cargo +perf-stage1 check':

          2,295.57 msec task-clock:u              #    0.996 CPUs utilized
                 0      context-switches:u        #    0.000 K/sec
                 0      cpu-migrations:u          #    0.000 K/sec
            49,959      page-faults:u             #    0.022 M/sec
     5,151,407,066      cycles:u                  #    2.244 GHz
       324,517,829      stalled-cycles-frontend:u #    6.30% frontend cycles idle
     2,301,671,001      stalled-cycles-backend:u  #   44.68% backend cycles idle
     8,130,868,329      instructions:u            #    1.58  insn per cycle
                                                  #    0.28  stalled cycles per insn
     1,356,618,512      branches:u                #  590.972 M/sec
         7,323,800      branch-misses:u           #    0.54% of all branches

       2.304509653 seconds time elapsed

       2.128090000 seconds user
       0.163909000 seconds sys
```
</details>
2020-09-29 02:29:13 +00:00
..
rustc just max_level_info 2020-09-11 09:37:51 -07:00
rustc_apfloat /nightly/nightly-rustc 2020-09-23 21:51:56 +02:00
rustc_arena Remove unused #[allow(...)] statements from compiler/ 2020-09-26 01:25:55 +02:00
rustc_ast tidy 2020-09-23 22:08:30 +02:00
rustc_ast_lowering simplfy condition in ItemLowerer::with_trait_impl_ref() 2020-09-16 23:09:57 +02:00
rustc_ast_passes use matches!() macro for simple if let conditions 2020-09-18 20:28:35 +02:00
rustc_ast_pretty Fully integrate token collection for additional AST structs 2020-09-10 17:58:14 -04:00
rustc_attr Remove `rustc_allow_const_fn_ptr` 2020-09-27 10:46:41 -07:00
rustc_builtin_macros Auto merge of #76485 - estebank:format_arg_capture_spans, r=davidtwco 2020-09-26 10:05:49 +00:00
rustc_codegen_llvm Rollup merge of #76839 - lzutao:mips-asm, r=Amanieu 2020-09-27 18:37:20 +02:00
rustc_codegen_ssa Rollup merge of #77208 - mati865:late-link-args-order, r=petrochenkov 2020-09-27 01:53:23 +02:00
rustc_data_structures Remove unused #[allow(...)] statements from compiler/ 2020-09-26 01:25:55 +02:00
rustc_driver Rollup merge of #76474 - bjorn3:driver_selected_codegen, r=oli-obk 2020-09-28 18:39:40 +02:00
rustc_error_codes Rollup merge of #76973 - lzutao:unstably-const-assume, r=oli-obk 2020-09-25 19:42:29 +02:00
rustc_errors /nightly/nightly-rustc 2020-09-23 21:51:56 +02:00
rustc_expand Remove redundant #![feature(...)] 's from compiler/ 2020-09-17 07:58:45 +02:00
rustc_feature Remove `rustc_allow_const_fn_ptr` 2020-09-27 10:46:41 -07:00
rustc_fs_util
rustc_graphviz /nightly/nightly-rustc 2020-09-23 21:51:56 +02:00
rustc_hir Auto merge of #76955 - jyn514:refactor-diagnostics, r=euclio 2020-09-27 08:12:29 +00:00
rustc_hir_pretty
rustc_incremental /nightly/nightly-rustc 2020-09-23 21:51:56 +02:00
rustc_index cache types during normalization 2020-09-19 17:27:13 +02:00
rustc_infer Revert "Add an unused field of type `Option<DefId>` to `ParamEnv` struct." 2020-09-26 21:01:09 -07:00
rustc_interface Add option to pass a custom codegen backend from a driver 2020-09-27 14:16:42 +02:00
rustc_lexer Fix typo in rustc_lexer docs 2020-09-21 05:43:39 +02:00
rustc_lint Separate `private_intra_doc_links` and `broken_intra_doc_links` into separate lints 2020-09-27 09:58:29 -04:00
rustc_llvm Remove unused #[allow(...)] statements from compiler/ 2020-09-26 01:25:55 +02:00
rustc_macros Remove unused #[allow(...)] statements from compiler/ 2020-09-26 01:25:55 +02:00
rustc_metadata Auto merge of #77118 - exrook:stability-generic-parameters-2, r=varkor 2020-09-27 12:51:21 +00:00
rustc_middle Auto merge of #77257 - ecstatic-morse:optimize-int-range-from-pat, r=Mark-Simulacrum 2020-09-29 02:29:13 +00:00
rustc_mir Auto merge of #77302 - RalfJung:rollup-n8gg3v6, r=RalfJung 2020-09-28 18:02:45 +00:00
rustc_mir_build Speed up `IntRange::from_pat` 2020-09-26 20:00:54 -07:00
rustc_parse pretty-print-reparse hack: Remove an impossible case 2020-09-26 20:27:14 +03:00
rustc_parse_format /nightly/nightly-rustc 2020-09-23 21:51:56 +02:00
rustc_passes Auto merge of #77229 - tmiasko:liveness, r=lcnr 2020-09-27 19:38:01 +00:00
rustc_plugin_impl /nightly/nightly-rustc 2020-09-23 21:51:56 +02:00
rustc_privacy /nightly/nightly-rustc 2020-09-23 21:51:56 +02:00
rustc_query_system update the version of itertools and parking_lot 2020-09-12 08:26:53 +02:00
rustc_resolve /nightly/nightly-rustc 2020-09-23 21:51:56 +02:00
rustc_save_analysis /nightly/nightly-rustc 2020-09-23 21:51:56 +02:00
rustc_serialize Deduplicate and generalize some (de/)serializer impls 2020-09-26 14:55:42 +02:00
rustc_session [mir-opt] Introduce a new flag to enable experimental/unsound mir opts 2020-09-27 19:21:01 -04:00
rustc_span Rollup merge of #77170 - ecstatic-morse:const-fn-ptr, r=oli-obk 2020-09-28 18:39:44 +02:00
rustc_symbol_mangling Implement `Display` for `DisambiguatedDefPathData` and `DefPathData` 2020-09-25 22:46:15 +01:00
rustc_target Rollup merge of #76839 - lzutao:mips-asm, r=Amanieu 2020-09-27 18:37:20 +02:00
rustc_trait_selection Revert "Add an unused field of type `Option<DefId>` to `ParamEnv` struct." 2020-09-26 21:01:09 -07:00
rustc_traits Update chalk to 0.29.0 2020-09-27 15:54:07 +02:00
rustc_ty Rollup merge of #77155 - lcnr:ImplSource, r=ecstatic-morse 2020-09-25 19:42:48 +02:00
rustc_typeck Rollup merge of #76711 - davidtwco:issue-51154-param-closure, r=estebank 2020-09-28 18:39:42 +02:00