Repository: rust
Issue: Incremental compilation regression with num-bignum
Labels: I-slow,C-enhancement,T-compiler,A-incr-comp

The num-bignum crate is slower by a factor 3-4 when compiling incrementally.

This crate supports `cargo bench` which allows for an easy comparison of the performance.
Without incremental compilation (`CARGO_INCREMENTAL=0 cargo bench`):
```
test divide_0          ... bench:         867 ns/iter (+/- 17)
test divide_1          ... bench:      15,398 ns/iter (+/- 361)
test divide_2          ... bench:     770,862 ns/iter (+/- 14,336)
test fac_to_string     ... bench:       2,210 ns/iter (+/- 7)
test factorial_100     ... bench:       6,624 ns/iter (+/- 382)
test fib2_100          ... bench:       1,777 ns/iter (+/- 54)
test fib2_1000         ... bench:      33,224 ns/iter (+/- 1,143)
test fib2_10000        ... bench:   2,109,744 ns/iter (+/- 21,395)
test fib_100           ... bench:         871 ns/iter (+/- 30)
test fib_1000          ... bench:      15,811 ns/iter (+/- 467)
test fib_10000         ... bench:   1,037,026 ns/iter (+/- 32,844)
test fib_to_string     ... bench:         232 ns/iter (+/- 4)
test from_str_radix_02 ... bench:       2,671 ns/iter (+/- 50)
test from_str_radix_08 ... bench:       1,157 ns/iter (+/- 18)
test from_str_radix_10 ... bench:       1,348 ns/iter (+/- 61)
test from_str_radix_16 ... bench:       1,029 ns/iter (+/- 25)
test from_str_radix_36 ... bench:       1,069 ns/iter (+/- 38)
test hash              ... bench:      78,637 ns/iter (+/- 2,226)
test modpow            ... bench:  24,375,306 ns/iter (+/- 541,434)
test modpow_even       ... bench:  62,169,859 ns/iter (+/- 1,558,466)
test multiply_0        ... bench:         100 ns/iter (+/- 2)
test multiply_1        ... bench:      15,523 ns/iter (+/- 445)
test multiply_2        ... bench:     848,662 ns/iter (+/- 18,692)
test multiply_3        ... bench:   1,972,284 ns/iter (+/- 41,682)
test pow_bench         ... bench:   5,377,001 ns/iter (+/- 173,286)
test shl               ... bench:       4,543 ns/iter (+/- 166)
test shr               ... bench:       1,984 ns/iter (+/- 103)
test to_str_radix_02   ... bench:       2,196 ns/iter (+/- 65)
test to_str_radix_08   ... bench:         772 ns/iter (+/- 16)
test to_str_radix_10   ... bench:       6,922 ns/iter (+/- 209)
test to_str_radix_16   ... bench:         637 ns/iter (+/- 12)
test to_str_radix_36   ... bench:       6,851 ns/iter (+/- 190)

test result: ok. 0 passed; 0 failed; 0 ignored; 32 measured; 0 filtered out

     Running target/release/deps/gcd-c7301f4be4104d87

running 8 tests
test gcd_euclid_0064 ... bench:       9,621 ns/iter (+/- 380)
test gcd_euclid_0256 ... bench:      57,871 ns/iter (+/- 1,377)
test gcd_euclid_1024 ... bench:     268,900 ns/iter (+/- 6,397)
test gcd_euclid_4096 ... bench:   1,786,538 ns/iter (+/- 50,910)
test gcd_stein_0064  ... bench:       1,589 ns/iter (+/- 74)
test gcd_stein_0256  ... bench:       6,351 ns/iter (+/- 106)
test gcd_stein_1024  ... bench:      39,651 ns/iter (+/- 1,787)
test gcd_stein_4096  ... bench:     351,423 ns/iter (+/- 18,916)
```

With incremental compilation:
```
test divide_0          ... bench:       2,212 ns/iter (+/- 120)
test divide_1          ... bench:      46,185 ns/iter (+/- 1,319)
test divide_2          ... bench:   2,164,688 ns/iter (+/- 35,890)
test fac_to_string     ... bench:       3,051 ns/iter (+/- 41)
test factorial_100     ... bench:      18,034 ns/iter (+/- 427)
test fib2_100          ... bench:       6,455 ns/iter (+/- 224)
test fib2_1000         ... bench:     119,590 ns/iter (+/- 2,451)
test fib2_10000        ... bench:   6,462,893 ns/iter (+/- 129,404)
test fib_100           ... bench:       3,026 ns/iter (+/- 65)
test fib_1000          ... bench:      56,443 ns/iter (+/- 1,542)
test fib_10000         ... bench:   3,210,114 ns/iter (+/- 64,889)
test fib_to_string     ... bench:         433 ns/iter (+/- 40)
test from_str_radix_02 ... bench:       7,403 ns/iter (+/- 288)
test from_str_radix_08 ... bench:       2,741 ns/iter (+/- 99)
test from_str_radix_10 ... bench:       3,737 ns/iter (+/- 115)
test from_str_radix_16 ... bench:       2,830 ns/iter (+/- 78)
test from_str_radix_36 ... bench:       3,354 ns/iter (+/- 80)
test hash              ... bench:     140,451 ns/iter (+/- 2,757)
test modpow            ... bench:  78,250,953 ns/iter (+/- 1,400,794)
test modpow_even       ... bench: 191,208,389 ns/iter (+/- 10,505,051)
test multiply_0        ... bench:         396 ns/iter (+/- 12)
test multiply_1        ... bench:      45,034 ns/iter (+/- 1,049)
test multiply_2        ... bench:   3,110,243 ns/iter (+/- 114,081)
test multiply_3        ... bench:   7,193,430 ns/iter (+/- 498,651)
test pow_bench         ... bench:  13,125,197 ns/iter (+/- 1,299,791)
test shl               ... bench:       7,582 ns/iter (+/- 739)
test shr               ... bench:       3,056 ns/iter (+/- 58)
test to_str_radix_02   ... bench:       5,011 ns/iter (+/- 130)
test to_str_radix_08   ... bench:       1,877 ns/iter (+/- 29)
test to_str_radix_10   ... bench:       8,457 ns/iter (+/- 287)
test to_str_radix_16   ... bench:       1,401 ns/iter (+/- 45)
test to_str_radix_36   ... bench:       7,998 ns/iter (+/- 159)

test result: ok. 0 passed; 0 failed; 0 ignored; 32 measured; 0 filtered out

     Running target/release/deps/gcd-c7301f4be4104d87

running 8 tests
test gcd_euclid_0064 ... bench:      19,747 ns/iter (+/- 548)
test gcd_euclid_0256 ... bench:     119,759 ns/iter (+/- 1,850)
test gcd_euclid_1024 ... bench:     569,027 ns/iter (+/- 12,593)
test gcd_euclid_4096 ... bench:   4,087,824 ns/iter (+/- 538,444)
test gcd_stein_0064  ... bench:       6,511 ns/iter (+/- 2,291)
test gcd_stein_0256  ... bench:      25,980 ns/iter (+/- 1,552)
test gcd_stein_1024  ... bench:     138,574 ns/iter (+/- 5,185)
test gcd_stein_4096  ... bench:     989,603 ns/iter (+/- 42,293)
```

num-bigint: f656829
cargo: 0.26.0-nightly (1d6dfea44 2018-01-26)
rustc: 1.25.0-nightly (27a046e93 2018-02-18)