You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Orbit release build of glium takes a very long time in codegen passes #34166
clone glium and check out glium/glium@11a6b7b (most recent commit at the time of writing)
try a -Zorbit release build with the current nightly (2016-06-07):
For me, this involved env RUSTFLAGS="-Zorbit" rustup run nightly cargo rustc --release -- -Ztime-passes
Observe compilation progress (very slowly but steadily, in old Rust tradition) until llvm module passes, which itself takes about 24 seconds on my machine, and then get stuck somewhere in LLVM codegen
cc @eddyb (I heard you like nothing more than MIR trans and LLVM bugs)
So it seems like there are multiple issues at play here. Let me try to sum up what @eddyb and me managed to dig up a few days ago:
gl-rs generates Rust code for loading OpenGL function pointers, and the generated code isn't quite optimal:
in fact, it generates 1624 lines of code for initializing the Gl struct, each of which performs 2 function calls
this can be seen in target/debug/build/glium-*/out/gl_bindings.rs when building manually
MIR trans generates a lot more LLVM values than old trans
in fact, the bad function results in 13001 values for old trans, but in 64978 values (!) for MIR trans (all unoptimized)
this is still fine, since the unoptimized MIR build works
after optimizations, old trans uses 53594 values, while MIR trans uses 61714 - MIR trans uses less than before, so this point might be moot (⬅️this might also indicate that the LLVM inliner should take the caller's size into account when deciding whether to inline or not)
LLVM's greedy register allocator seems to have some bad performance characteristics
in fact, the build spends over 5 minutes in there until I cancelled it (see the gist linked below)
specifying a different allocator by using llc --regalloc=X makes the code compile successfully
I'm really not sure why this all works out without optimizations but fails with them, but it seems like the greedy register allocator is partially at fault here. Of course it's the greedy allocator, it is used by default for an optimized build, while the "fast" allocator is used for debug builds.
Hm doesn't look familiar to me, so it may or may not have been (sorry not much help on this one).
If codegen is generating so much code though it seems like this is something that should arguably be fixed in upstream at the same time the MIR regression is fixed...
Discussed in compiler team meeting. @arielb1 will try to produce a stand-alone test case. Seems like doing some "NRVO-style" optimization may be the best answer here.
One question is whether the workaround that @arielb1 suggested has been applied for glium? @arielb1 at least is of the opinion that (if so) this need not block moving to MIR more broadly, as there are many possible O(n^2) cases we could hit, even in old trans (even if this code was not among them). Though I'd still like to see it fixed =)
changed the title [-]Orbit release build of glium gets stuck in codegen passes[/-][+]Orbit release build of glium takes a very long time in codegen passes[/+]on Jul 28, 2016
Removing from the "launch MIR into orbit" milestone for the following reasons:
The problem with glium specifically is not present in the latest release.
As @arielb1 argues, there are many sources of "O(n^2)" behavior in LLVM (not to argue we shouldn't try to fix this one), some of which are present in old trans, some in MIR trans.
We do plan to address this source by working on optimizations like move-forwarding etc
Gaining experience with MIR in nightly seems very valuable
I have a project (closed source) that can't compile on nightly/release but compiles fine on stable and nightly/debug.
I've stop waiting after more than 20 mins (stable compiles in about 1 min).
When running cargo rustc --release -- -Ztime-passes, the last step I see is:
time: 1.014; rss: 121MB llvm function passes [0]
So I assume the next step (which is llvm module passes [0] on stable) is having a problem on my system.
I'm using
Is there any command I can run to explore in more details what is happening?
Also I don't know how to try another allocator as specified in this comment
Activity
jonas-schievink commentedon Jun 8, 2016
Output of
perfafter a while:arielb1 commentedon Jun 8, 2016
Could you
-C llvm-args=-print-before-all?jonas-schievink commentedon Jun 8, 2016
@arielb1 That somehow managed to lock up rustc (using 0% cpu) before getting to codegen (or even optimizations). Fun!
jonas-schievink commentedon Jun 8, 2016
Here's the last part of it:
https://gist.github.com/jonas-schievink/c2599dd9f9687c907773ddb05f381430
jonas-schievink commentedon Jun 11, 2016
So it seems like there are multiple issues at play here. Let me try to sum up what @eddyb and me managed to dig up a few days ago:
gl-rsgenerates Rust code for loading OpenGL function pointers, and the generated code isn't quite optimal:Glstruct, each of which performs 2 function callstarget/debug/build/glium-*/out/gl_bindings.rswhen building manuallyllc --regalloc=Xmakes the code compile successfullyI'm really not sure why this all works out without optimizations but fails with them, but it seems like the greedy register allocator is partially at fault here.Of course it's the greedy allocator, it is used by default for an optimized build, while the "fast" allocator is used for debug builds.For details, refer to this gist.
eddyb commentedon Jun 11, 2016
cc @alexcrichton Any chance this was already found and fixed upstream?
alexcrichton commentedon Jun 11, 2016
Hm doesn't look familiar to me, so it may or may not have been (sorry not much help on this one).
If codegen is generating so much code though it seems like this is something that should arguably be fixed in upstream at the same time the MIR regression is fixed...
eddyb commentedon Jun 11, 2016
Found something https://llvm.org/bugs/show_bug.cgi?id=19217 - and an older one https://llvm.org/bugs/show_bug.cgi?id=11811.
None of these bugs seem to have had much progress on them.
The cleanup one would suggest a potential reason for why MIR trans displays the problem.
Auto merge of #34290 - arielb1:short-ladder, r=eddyb
arielb1 commentedon Jun 16, 2016
I blame the LLVM inliner. This can be fixed by moving
metaloadfnto a#[inline(never)]function:That still leaves MIR ~20% slower, so there may be still some issue, but if at least finishes.
arielb1 commentedon Jun 16, 2016
The unoptimized "unit cell" we generate is
In LLVM, that becomes
Very ugly. Pair-passing style + lack of DPS means we have to spill out lots of things.
NRVO should fix this.
6 remaining items
eddyb commentedon Jul 28, 2016
@jonas-schievink
HangsTakes ages in release +-Z orbit, both ongliummaster and the original revision, for me.For master, i.e. glium/glium@66d0b5b:
EDIT: This was with an older
Cargo.lock, andCargodidn't react to me updating the repo itself.It finishes in about a minute otherwise.
nikomatsakis commentedon Jul 28, 2016
Discussed in compiler team meeting. @arielb1 will try to produce a stand-alone test case. Seems like doing some "NRVO-style" optimization may be the best answer here.
nikomatsakis commentedon Jul 28, 2016
One question is whether the workaround that @arielb1 suggested has been applied for glium? @arielb1 at least is of the opinion that (if so) this need not block moving to MIR more broadly, as there are many possible O(n^2) cases we could hit, even in old trans (even if this code was not among them). Though I'd still like to see it fixed =)
[-]Orbit release build of glium gets stuck in codegen passes[/-][+]Orbit release build of glium takes a very long time in codegen passes[/+]jonas-schievink commentedon Jul 28, 2016
Glium is still on gl_generator 0.5.1, the fix is in 0.5.2
EDIT: Ah nevermind, Cargo will update to 0.5.2 anyways :)
arielb1 commentedon Jul 28, 2016
self-contained, but not minified, example at www.cs.tau.ac.il/~arielb1/gl-bindings-self-contained-1.rs.xz
Because of how the O(n^2)-ess works, this only takes a few seconds to codegen, but still an anomalously high time,
eddyb commentedon Jul 28, 2016
@jonas-schievink Oops! Totally my bad, I had a stale
Cargo.lock.arielb1 commentedon Jul 28, 2016
minified example: http://sprunge.us/fGMM (2kLoC - macro magic should be reduce this)
arielb1 commentedon Jul 28, 2016
Template:
nikomatsakis commentedon Aug 1, 2016
Removing from the "launch MIR into orbit" milestone for the following reasons:
tafia commentedon Nov 28, 2016
Is there any news on this?
I have a project (closed source) that can't compile on nightly/release but compiles fine on stable and nightly/debug.
I've stop waiting after more than 20 mins (stable compiles in about 1 min).
When running
cargo rustc --release -- -Ztime-passes, the last step I see is:So I assume the next step (which is
llvm module passes [0]on stable) is having a problem on my system.I'm using
Is there any command I can run to explore in more details what is happening?
Also I don't know how to try another allocator as specified in this comment
ishitatsuyuki commentedon May 3, 2018
Closing this due to inactivity. This was probably a LLVM bug, which may have been already fixed today.
If the issue happens on the same code, please request to reopen. If a similar issue happens with different code, please open a new issue with that.