Repository: rust
Issue: Compile time regression with _large_ number of slices
Labels: C-enhancement,E-needs-test,I-compiletime,T-compiler

cc https://github.com/behnam/rust-unic/issues/199

The simplest way to show this is to use [`unic_ucd_name` 0.6.0](https://crates.io/crates/unic-ucd-name/0.6.0), which has two huge files for the Unicode code point Name property, [`name_map.rsv`](https://github.com/behnam/rust-unic/blob/v0.6.0/unic/ucd/name/tables/name_map.rsv) (1.56 MB of `('character', &[PARTS, OF, ITS, NAME]),`) and [`name_values.rsd`](https://github.com/behnam/rust-unic/blob/v0.6.0/unic/ucd/name/tables/name_values.rsd) (444 KB of `const NAME_BIT: &str = "NAME_BIT";`). The purpose is to generate a large binary-search slice from characters to their name while deduplicating _very_ common name fragments like `LETTER`.

With this small `main.rs`

```rust
extern crate unic_ucd_name;

fn main() {
    let name = unic_ucd_name::Name::of('A').unwrap();
    println!("{}", name);
}
```

and a non-existent `target` folder, I get the following compile times:

```
D:\Christopher\Documents\Code\Rust\playground>rustup update
info: syncing channel updates for 'stable-x86_64-pc-windows-msvc'
info: syncing channel updates for 'beta-x86_64-pc-windows-msvc'
info: syncing channel updates for 'nightly-x86_64-pc-windows-msvc'
info: checking for self-updates

   stable-x86_64-pc-windows-msvc unchanged - rustc 1.23.0 (766bd11c8 2018-01-01)
     beta-x86_64-pc-windows-msvc unchanged - rustc 1.24.0-beta.11 (03f456d3c 2018-02-03)
  nightly-x86_64-pc-windows-msvc unchanged - rustc 1.25.0-nightly (0c6091fbd 2018-02-04)

D:\Christopher\Documents\Code\Rust\playground>cargo +beta build
   Compiling unic-ucd-core v0.6.0
   Compiling unic-char-range v0.6.0
   Compiling unic-utils v0.6.0
   Compiling unic-ucd-name v0.6.0
   Compiling playground v0.0.0 (file:///D:/Christopher/Documents/Code/Rust/playground)
    Finished dev [unoptimized + debuginfo] target(s) in 18.23 secs

D:\Christopher\Documents\Code\Rust\playground>cargo +nightly build
   Compiling unic-char-range v0.6.0
   Compiling unic-ucd-core v0.6.0
   Compiling unic-utils v0.6.0
   Compiling unic-ucd-name v0.6.0
   Compiling playground v0.0.0 (file:///D:/Christopher/Documents/Code/Rust/playground)
    Finished dev [unoptimized + debuginfo] target(s) in 139.35 secs
```

<details><summary><code>time-passes</code> for <code>unic_ucd_name</code></summary>

```
D:\Christopher\Documents\Code\Rust\rust-unic\unic\ucd\name>cargo +nightly rustc -- -Z time-passes
   Compiling unic-char-range v0.6.0 (file:///D:/Christopher/Documents/Code/Rust/rust-unic/unic/char/range)
   Compiling unic-ucd-core v0.6.0 (file:///D:/Christopher/Documents/Code/Rust/rust-unic/unic/ucd/core)
   Compiling unic-utils v0.6.0 (file:///D:/Christopher/Documents/Code/Rust/rust-unic/unic/utils)
   Compiling unic-ucd-name v0.6.0 (file:///D:/Christopher/Documents/Code/Rust/rust-unic/unic/ucd/name)
  time: 0.009; rss: 17MB        parsing
  time: 0.000; rss: 18MB        recursion limit
  time: 0.000; rss: 18MB        crate injection
  time: 0.000; rss: 18MB        plugin loading
  time: 0.000; rss: 18MB        background load prev dep-graph
  time: 0.000; rss: 18MB        plugin registration
  time: 0.654; rss: 105MB       expansion
  time: 0.000; rss: 105MB       maybe building test harness
  time: 0.010; rss: 105MB       maybe creating a macro crate
  time: 0.032; rss: 105MB       creating allocators
  time: 0.010; rss: 105MB       AST validation
  time: 0.122; rss: 122MB       name resolution
  time: 0.027; rss: 122MB       complete gated feature checking
  time: 0.000; rss: 122MB       blocked while dep-graph loading finishes
  time: 0.145; rss: 170MB       lowering ast -> hir
  time: 0.056; rss: 170MB       early lint checks
  time: 0.178; rss: 179MB       indexing hir
  time: 0.000; rss: 122MB       load query result cache
  time: 0.000; rss: 122MB       looking for entry point
  time: 0.000; rss: 122MB       looking for plugin registrar
  time: 0.011; rss: 122MB       loop checking
  time: 0.040; rss: 122MB       static item recursion checking
  time: 0.041; rss: 135MB       attribute checking
  time: 0.063; rss: 144MB       stability checking
  time: 0.293; rss: 202MB       type collecting
  time: 0.002; rss: 202MB       outlives testing
  time: 0.000; rss: 202MB       impl wf inference
  time: 0.047; rss: 220MB       coherence checking
  time: 0.002; rss: 220MB       variance testing
  time: 0.248; rss: 261MB       wf checking
  time: 4.396; rss: 337MB       item-types checking
  time: 0.032; rss: 341MB       item-bodies checking
  time: 126.260; rss: 550MB     const checking          # !!!!!!!!!!
  time: 0.183; rss: 551MB       privacy checking
  time: 0.025; rss: 551MB       intrinsic checking
  time: 0.046; rss: 552MB       match checking
  time: 0.011; rss: 552MB       liveness checking
  time: 0.554; rss: 561MB       borrow checking
  time: 0.026; rss: 564MB       MIR borrow checking
  time: 0.008; rss: 564MB       MIR effect checking
  time: 0.049; rss: 565MB       death checking
  time: 0.000; rss: 565MB       unused lib feature checking
  time: 0.166; rss: 565MB       lint checking
  time: 0.000; rss: 565MB       resolving dependency formats
    time: 1.136; rss: 615MB     write metadata
    time: 0.108; rss: 618MB     translation item collection
    time: 0.002; rss: 618MB     codegen unit partitioning
    time: 0.001; rss: 635MB     llvm function passes [49a7n47po4ttqjl7]
    time: 0.001; rss: 635MB     llvm module passes [49a7n47po4ttqjl7]
    time: 0.000; rss: 636MB     llvm function passes [3ayaeypdcro9d6yk]
    time: 0.000; rss: 636MB     llvm module passes [3ayaeypdcro9d6yk]
    time: 0.000; rss: 636MB     llvm function passes [3kfx4ynvkmi2y9i5]
    time: 0.000; rss: 636MB     llvm module passes [3kfx4ynvkmi2y9i5]
    time: 0.000; rss: 636MB     llvm function passes [45nf4z58qqykpcpi]
    time: 0.000; rss: 636MB     llvm module passes [45nf4z58qqykpcpi]
    time: 0.000; rss: 637MB     llvm function passes [kt25z0521ngsjub]
    time: 0.000; rss: 637MB     llvm module passes [kt25z0521ngsjub]
    time: 0.000; rss: 639MB     llvm function passes [2ny9ynlpevlhfa8x]
    time: 0.000; rss: 640MB     llvm module passes [2ny9ynlpevlhfa8x]
    time: 0.001; rss: 642MB     llvm function passes [1im38lueib99jsk0]
    time: 0.000; rss: 644MB     llvm module passes [1im38lueib99jsk0]
    time: 0.019; rss: 654MB     codegen passes [3kfx4ynvkmi2y9i5]
    time: 0.024; rss: 656MB     codegen passes [3ayaeypdcro9d6yk]
    time: 0.014; rss: 657MB     codegen passes [45nf4z58qqykpcpi]
    time: 0.016; rss: 658MB     codegen passes [kt25z0521ngsjub]
    time: 0.001; rss: 658MB     llvm function passes [2lyh15q6cjwzy18c]
    time: 0.000; rss: 659MB     llvm module passes [2lyh15q6cjwzy18c]
    time: 0.015; rss: 659MB     codegen passes [2ny9ynlpevlhfa8x]
    time: 0.036; rss: 659MB     codegen passes [49a7n47po4ttqjl7]
    time: 0.012; rss: 659MB     codegen passes [1im38lueib99jsk0]
    time: 0.010; rss: 659MB     codegen passes [2lyh15q6cjwzy18c]
    time: 0.000; rss: 677MB     llvm function passes [4ypvbwho0bu5tnww]
    time: 0.000; rss: 677MB     llvm module passes [4ypvbwho0bu5tnww]
    time: 0.000; rss: 677MB     llvm function passes [43v6g0y2xsxoggnt]
    time: 0.000; rss: 678MB     llvm function passes [9elsx31vb4it187]
    time: 0.000; rss: 678MB     llvm function passes [16u6js6g0l3k1ic6]
    time: 0.000; rss: 678MB     llvm module passes [43v6g0y2xsxoggnt]
    time: 0.000; rss: 678MB     llvm function passes [3e8c0xfx7ikmlnfk]
    time: 0.000; rss: 678MB     llvm module passes [9elsx31vb4it187]
    time: 0.000; rss: 680MB     llvm function passes [9fcb3syd3ne5k0n]
    time: 0.000; rss: 679MB     llvm module passes [16u6js6g0l3k1ic6]
    time: 0.000; rss: 679MB     llvm function passes [8xzrsc1ux72v29j]
    time: 0.000; rss: 679MB     llvm module passes [3e8c0xfx7ikmlnfk]
    time: 0.000; rss: 679MB     llvm module passes [9fcb3syd3ne5k0n]
    time: 0.000; rss: 679MB     llvm module passes [8xzrsc1ux72v29j]
    time: 0.017; rss: 679MB     codegen passes [4ypvbwho0bu5tnww]
    time: 0.013; rss: 679MB     codegen passes [9elsx31vb4it187]
    time: 0.018; rss: 679MB     codegen passes [43v6g0y2xsxoggnt]
    time: 0.000; rss: 679MB     llvm function passes [c6lbtaiefvx3wya]
    time: 0.016; rss: 679MB     codegen passes [16u6js6g0l3k1ic6]
    time: 0.000; rss: 679MB     llvm module passes [c6lbtaiefvx3wya]
    time: 0.000; rss: 679MB     llvm function passes [2kjrmm4fe2aha78f]
    time: 0.000; rss: 679MB     llvm function passes [4ezmh1vbs95c5ack]
    time: 0.013; rss: 679MB     codegen passes [9fcb3syd3ne5k0n]
    time: 0.000; rss: 679MB     llvm module passes [2kjrmm4fe2aha78f]
    time: 0.000; rss: 679MB     llvm function passes [2jqywn86b2gsqohu]
    time: 0.000; rss: 679MB     llvm module passes [4ezmh1vbs95c5ack]
    time: 0.015; rss: 679MB     codegen passes [3e8c0xfx7ikmlnfk]
    time: 0.000; rss: 679MB     llvm function passes [4yh8x2b62dcih00t]
    time: 0.000; rss: 681MB     llvm module passes [4yh8x2b62dcih00t]
    time: 0.017; rss: 681MB     codegen passes [8xzrsc1ux72v29j]
    time: 0.000; rss: 679MB     llvm module passes [2jqywn86b2gsqohu]
    time: 0.000; rss: 681MB     llvm function passes [1mvmz58owquyropc]
    time: 0.074; rss: 681MB     llvm function passes [2iv7jmandrgcbb7e]
    time: 0.000; rss: 681MB     llvm module passes [1mvmz58owquyropc]
    time: 0.000; rss: 681MB     llvm function passes [4xq48u46a1pwiqn7]
    time: 0.013; rss: 681MB     codegen passes [c6lbtaiefvx3wya]
    time: 0.000; rss: 681MB     llvm module passes [2iv7jmandrgcbb7e]
    time: 0.000; rss: 681MB     llvm module passes [4xq48u46a1pwiqn7]
    time: 0.000; rss: 677MB     llvm function passes [48721dc4k5qxei0u]
    time: 0.015; rss: 677MB     codegen passes [2kjrmm4fe2aha78f]
    time: 0.000; rss: 677MB     llvm module passes [48721dc4k5qxei0u]
    time: 0.000; rss: 677MB     llvm function passes [98g0d9x8aw3akpe]
    time: 0.000; rss: 677MB     llvm module passes [98g0d9x8aw3akpe]
    time: 0.022; rss: 677MB     codegen passes [4ezmh1vbs95c5ack]
    time: 0.023; rss: 677MB     codegen passes [4yh8x2b62dcih00t]
    time: 0.000; rss: 677MB     llvm function passes [2f0hry2t7c05ttdi]
    time: 0.000; rss: 677MB     llvm module passes [2f0hry2t7c05ttdi]
    time: 0.000; rss: 678MB     llvm function passes [1dqvxks6k2bzkxe]
    time: 0.018; rss: 678MB     codegen passes [1mvmz58owquyropc]
    time: 0.000; rss: 678MB     llvm module passes [1dqvxks6k2bzkxe]
    time: 0.019; rss: 678MB     codegen passes [2jqywn86b2gsqohu]
    time: 0.000; rss: 678MB     llvm function passes [23tqyymcb18u96mb]
    time: 0.000; rss: 678MB     llvm module passes [23tqyymcb18u96mb]
    time: 0.000; rss: 678MB     llvm function passes [4jdnq7xfjeka1bt]
    time: 0.000; rss: 678MB     llvm module passes [4jdnq7xfjeka1bt]
    time: 0.029; rss: 678MB     codegen passes [4xq48u46a1pwiqn7]
    time: 0.000; rss: 679MB     llvm function passes [1y16o1qfye96o7m0]
    time: 0.000; rss: 679MB     llvm module passes [1y16o1qfye96o7m0]
    time: 0.014; rss: 679MB     codegen passes [48721dc4k5qxei0u]
    time: 0.705; rss: 679MB     translate to LLVM IR
    time: 0.000; rss: 679MB     assert dep graph
    time: 0.000; rss: 679MB     llvm function passes [v6ozwtpojmqfurc]
    time: 0.000; rss: 679MB     llvm module passes [v6ozwtpojmqfurc]
    time: 0.012; rss: 679MB     codegen passes [98g0d9x8aw3akpe]
    time: 0.000; rss: 679MB     llvm function passes [524bze3gcv99ucga]
    time: 0.000; rss: 679MB     llvm module passes [524bze3gcv99ucga]
    time: 0.012; rss: 680MB     codegen passes [2f0hry2t7c05ttdi]
    time: 0.000; rss: 680MB     llvm function passes [2r82puffnvvb8iic]
    time: 0.000; rss: 680MB     llvm module passes [2r82puffnvvb8iic]
    time: 0.014; rss: 681MB     codegen passes [1dqvxks6k2bzkxe]
    time: 0.013; rss: 681MB     codegen passes [4jdnq7xfjeka1bt]
    time: 0.014; rss: 681MB     codegen passes [23tqyymcb18u96mb]
    time: 0.000; rss: 681MB     llvm function passes [2xnvmuhjbhd7vxcm]
    time: 0.000; rss: 681MB     llvm module passes [2xnvmuhjbhd7vxcm]
    time: 0.012; rss: 683MB     codegen passes [1y16o1qfye96o7m0]
    time: 0.010; rss: 683MB     codegen passes [2r82puffnvvb8iic]
    time: 0.011; rss: 683MB     codegen passes [524bze3gcv99ucga]
    time: 0.011; rss: 683MB     codegen passes [v6ozwtpojmqfurc]
    time: 0.006; rss: 686MB     codegen passes [2xnvmuhjbhd7vxcm]
      time: 0.543; rss: 690MB   persist query result cache
      time: 0.146; rss: 725MB   persist dep-graph
    time: 0.690; rss: 725MB     serialize dep graph
  time: 2.837; rss: 725MB       translation
    time: 1.168; rss: 275MB     codegen passes [2iv7jmandrgcbb7e]
  time: 2.562; rss: 237MB       LLVM passes
  time: 0.005; rss: 237MB       serialize work products
  time: 0.491; rss: 237MB       linking
    Finished dev [unoptimized + debuginfo] target(s) in 141.52 secs
```
</details>

(`x86_64-pc-windows-msvc`)