Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upLong compilation time due to LLVM creating excessive landing pads #41696
Comments
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
|
@kennytm versions I tried: 2017-03-28, 2017-04-22 and 2017-04-30.
Also tried on different linux boxes - same problem. |
This comment has been minimized.
This comment has been minimized.
|
@not-fl3 Could you specifically test with 2017-03-18 and 2017-03-19? You may install it from rustup using
|
This comment has been minimized.
This comment has been minimized.
|
@kennytm just tried continuously:
And first broken version is 2017-03-21.
|
This comment has been minimized.
This comment has been minimized.
|
@kennytm hmm it seems that on that 03-21 it hangs forever. It works for 20+ minutes and keep working slowly increasing consumed ram. |
This comment has been minimized.
This comment has been minimized.
|
The commit for 2017-03-21 is 1.17.0-nightly (134c4a0 2017-03-20) PRs between the two are
|
This comment has been minimized.
This comment has been minimized.
|
Could only reproduce with
The cause, is of course, the incremental compilation. |
nagisa
added
the
A-incr-comp
label
May 2, 2017
This comment has been minimized.
This comment has been minimized.
|
@kennytm https://gist.github.com/not-fl3/832b85ec9ff08537e479bb42ed4e2402 |
This comment has been minimized.
This comment has been minimized.
|
@kennytm checked your log from debian and found that in original post I used RUST_INCREMENTAL instead of CARGO_INCREMENTAL=1. |
This comment has been minimized.
This comment has been minimized.
|
Reduced test case: // rustc -Copt-level=2 -Zincremental=. main.rs
struct DS<U> {
name: String,
next: U,
}
fn add<U>(ds: DS<U>, name: String) -> DS<DS<U>> {
DS {
name: "?".to_owned(),
next: ds,
}
}
fn main() {
let deserializers = DS { name: "?".to_owned(), next: () };
let deserializers = add(deserializers, "?".to_owned());
let deserializers = add(deserializers, "?".to_owned());
let deserializers = add(deserializers, "?".to_owned());
let deserializers = add(deserializers, "?".to_owned());
let deserializers = add(deserializers, "?".to_owned());
let deserializers = add(deserializers, "?".to_owned());
let deserializers = add(deserializers, "?".to_owned()); // 0.7s
let deserializers = add(deserializers, "?".to_owned()); // 1.3s
let deserializers = add(deserializers, "?".to_owned()); // 2.4s
let deserializers = add(deserializers, "?".to_owned()); // 6.7s
// let deserializers = add(deserializers, "?".to_owned()); // 26.0s
// let deserializers = add(deserializers, "?".to_owned()); // 114.0s
}Looks like some exponential blow-up. In the 26s case, most time (51%) is spent on the RegisterCoalescer pass. |
This comment has been minimized.
This comment has been minimized.
kgv
commented
May 2, 2017
•
|
Looks like the same problem: fn main() {
let t: std::result::Result<(), ()> = Ok(());
let f = t
.into_future()
.and_then(|_| future::ok(()))
.and_then(|_| future::ok(()))
.and_then(|_| future::ok(()))
.and_then(|_| future::ok(()))
.and_then(|_| future::ok(())) // 0.69 secs
.and_then(|_| future::ok(()))
.and_then(|_| future::ok(()))
.and_then(|_| future::ok(()))
.and_then(|_| future::ok(())) // 1.94 secs
.and_then(|_| future::ok(()))
.and_then(|_| future::ok(()))
.and_then(|_| future::ok(()))
.and_then(|_| future::ok(())) // 20.68 secs
.and_then(|_| future::ok(())) // 40.58 secs
.and_then(|_| future::ok(())) // 80.70 secs
.and_then(|_| future::ok(())) // 160.59 secs
.and_then(|_| future::ok(())) // 321.88 secs
.and_then(|_| future::ok(())); // 642.42 secs
f.wait();
}run:
|
This comment has been minimized.
This comment has been minimized.
|
@kgv Not really the same issue. OP's code is slow to compile due to an LLVM pass, your code is slow to compile due to MIR optimization (specifically the "translation item collection" pass). |
arielb1
added
regression-from-stable-to-beta
T-compiler
labels
May 2, 2017
This comment has been minimized.
This comment has been minimized.
|
Adding |
brson
added
the
I-slow
label
May 4, 2017
This comment has been minimized.
This comment has been minimized.
brson
added
the
P-medium
label
May 4, 2017
This comment has been minimized.
This comment has been minimized.
|
Presumably this problem could also be triggered by using a larger number of codegen-units (instead of incremental), right? |
nikomatsakis
changed the title
Long compilation time with weird types on fresh nightlies
Long compilation time due to LLVM creating excessive landing pads
May 4, 2017
This comment has been minimized.
This comment has been minimized.
|
I don't quite understand how incremental compilation or the number of codegen units could interact with landing pad generation. |
This comment has been minimized.
This comment has been minimized.
|
Yeah |
This comment has been minimized.
This comment has been minimized.
|
No codegen-units needed: // rustc -Copt-level=2 main.rs
extern "C" {
static MAYBE: bool;
}
struct MayUnwind;
impl Drop for MayUnwind {
fn drop(&mut self) {
if unsafe { MAYBE } {
panic!()
}
}
}
struct DS<U> {
may_unwind: MayUnwind,
name: String,
next: U,
}
fn add<U>(ds: DS<U>, name: String) -> DS<DS<U>> {
DS {
may_unwind: MayUnwind,
name: "?".to_owned(),
next: ds,
}
}
fn main() {
let deserializers = DS { may_unwind: MayUnwind, name: "?".to_owned(), next: () };
let deserializers = add(deserializers, "?".to_owned());
let deserializers = add(deserializers, "?".to_owned());
let deserializers = add(deserializers, "?".to_owned());
let deserializers = add(deserializers, "?".to_owned());
let deserializers = add(deserializers, "?".to_owned());
let deserializers = add(deserializers, "?".to_owned());
let deserializers = add(deserializers, "?".to_owned()); // 0.7s
let deserializers = add(deserializers, "?".to_owned()); // 1.3s
let deserializers = add(deserializers, "?".to_owned()); // 2.4s
let deserializers = add(deserializers, "?".to_owned()); // 6.7s
// let deserializers = add(deserializers, "?".to_owned()); // 26.0s
// let deserializers = add(deserializers, "?".to_owned()); // 114.0s
} |
arielb1
added a commit
to arielb1/rust
that referenced
this issue
May 11, 2017
arielb1
referenced this issue
May 11, 2017
Merged
remove the #[inline] attribute from drop_in_place #41920
arielb1
added a commit
to arielb1/rust
that referenced
this issue
May 11, 2017
Mark-Simulacrum
added a commit
to Mark-Simulacrum/rust
that referenced
this issue
May 12, 2017
Mark-Simulacrum
added a commit
to Mark-Simulacrum/rust
that referenced
this issue
May 12, 2017
Mark-Simulacrum
added a commit
to Mark-Simulacrum/rust
that referenced
this issue
May 12, 2017
This comment has been minimized.
This comment has been minimized.
|
Root cause is https://bugs.llvm.org/show_bug.cgi?id=33072. This variant affects all versions of rustc including 1.8.0: fn f1(x: &mut u32) {
let odd = (-((*x & 1) as i32)) as u32;
*x = ((*x * 3 + 1) & odd)
+ ((*x / 2) & !odd);
}
fn f2(x: &mut u32) {
f1(x);
f1(x);
f1(x);
f1(x);
}
fn f3(x: &mut u32) {
f2(x);
f2(x);
f2(x);
f2(x);
}
fn f4(x: &mut u32) {
f3(x);
f3(x);
f3(x);
f3(x);
}
fn f5(x: &mut u32) {
f4(x);
f4(x);
f4(x);
f4(x);
}
fn f6(x: &mut u32) {
f5(x);
f5(x);
f5(x);
f5(x);
}
fn f7(x: &mut u32) {
f6(x);
f6(x);
f6(x);
f6(x);
}
fn f8(x: &mut u32) {
f7(x);
f7(x);
f7(x);
f7(x);
}
fn f9(x: &mut u32) {
f8(x);
f8(x);
f8(x);
f8(x);
}
fn fA(x: &mut u32) {
f9(x);
f9(x);
f9(x);
f9(x);
}
fn main() {
let mut x = 44;
fA(&mut x);
println!("{}", x);
} |
This comment has been minimized.
This comment has been minimized.
|
It looks like this is worked around for 1.18 right? |
michaelwoerister
removed
the
A-incr-comp
label
May 29, 2017
brson
added
the
A-LLVM
label
Jun 1, 2017
brson
assigned
arielb1
Jun 1, 2017
sanxiyn
added
I-compiletime
and removed
I-slow
labels
Jun 8, 2017
brson
added
regression-from-stable-to-stable
and removed
regression-from-stable-to-beta
labels
Jun 15, 2017
jonhoo
added a commit
to jonhoo/fantoccini
that referenced
this issue
Jun 20, 2017
This comment has been minimized.
This comment has been minimized.
|
@brson I don't think this is resolved. Take jonhoo/fantoccini@79e1683 for example. On current nightly ( |
arielb1
added a commit
to arielb1/rust
that referenced
this issue
Jun 20, 2017
arielb1
added a commit
to arielb1/rust
that referenced
this issue
Jun 20, 2017
bors
added a commit
that referenced
this issue
Jun 21, 2017
bors
closed this
in
#42771
Jun 22, 2017
This comment has been minimized.
This comment has been minimized.
|
@arielb1 #42771 still doesn't seem to solve this for me. EDIT: in fact, compile time seems to have gone up if anything. Used to be ~750s, now 925s... |
This comment has been minimized.
This comment has been minimized.
|
Going to tentatively reopen for now based on @jonhoo's report. |
bstrie
reopened this
Jun 23, 2017
This comment has been minimized.
This comment has been minimized.
|
Can you give me the output of compiling your program with |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
is pretty curious. the extra time is spent between when |
This comment has been minimized.
This comment has been minimized.
|
@arielb1: just checking that you saw my follow-up? |
This comment has been minimized.
This comment has been minimized.
|
I was a bit busy lately, but:
This bug causes excessive time in LLVM passes, not in translation, so I'm pretty sure it's a different bug. Please open a separate issue. |
not-fl3 commentedMay 2, 2017
•
edited
Long compilation time (almost infinity on real project) with every nightly versions after 2017-03-18.
I tried this:
I expected to see this happen:
On 2017-03-18 it compiles for less than a second (in 0.59 secs on my machine)
Instead, this happened:
With every version newer than 2017-03-18 it compiles for 389+ seconds on my machine.
Meta
rustc --version --verbose:Also same behaviour on this versions:
nightly-2017-03-28-x86_64-unknown-linux-gnunightly-2017-04-22-x86_64-unknown-linux-gnunightly-2017-04-30-x86_64-unknown-linux-gnuBacktrace:
log of -Z time-asses: https://gist.github.com/not-fl3/8c4ee411fe6c23d4b4abb9a3b6a263d0