-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Orbit release build of glium takes a very long time in codegen passes #34166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Output of
|
Could you |
@arielb1 That somehow managed to lock up rustc (using 0% cpu) before getting to codegen (or even optimizations). Fun! |
Here's the last part of it: https://gist.github.com/jonas-schievink/c2599dd9f9687c907773ddb05f381430 |
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:
For details, refer to this gist. |
cc @alexcrichton Any chance this was already found and fixed upstream? |
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... |
Found something https://llvm.org/bugs/show_bug.cgi?id=19217 - and an older one https://llvm.org/bugs/show_bug.cgi?id=11811. |
I blame the LLVM inliner. This can be fixed by moving #[inline(never)]
fn do_metaloadfn(loadfn: &mut FnMut(&str) -> *const __gl_imports::raw::c_void,
symbol: &str,
symbols: &[&str])
-> *const __gl_imports::raw::c_void
{
let mut ptr = loadfn(symbol);
if ptr.is_null() {
for &sym in symbols {
ptr = loadfn(sym);
if !ptr.is_null() { break; }
}
}
ptr
}
let mut metaloadfn = |symbol: &str, symbols: &[&str]| {
do_metaloadfn(&mut loadfn, symbol, symbols)
}; That still leaves MIR ~20% slower, so there may be still some issue, but if at least finishes. |
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. |
I commented in #25478, as the compilation is able to pull through. However it's probably related as I use |
Added to the milestone so it's tracked until it gets fixed. |
@arielb1 can you elaborate a bit on your comment. For example:
What do you mean by "unit cell"? What is the Rust code from which this is generated?
Same question :) what is the rust code? What is "pair-passing style"? Let me take my best guess :). I think by "pair passing style" you are referring to the rust-call convention, where we are tupling up the arguments? Certainly I see that in your snippet, e.g. in the creation of |
Is this in any way platform specific? |
This happened on x64 Arch Linux, but I can't reproduce it anymore:
|
@jonas-schievink For master, i.e. glium/glium@66d0b5b:
EDIT: This was with an older |
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 =) |
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 :) |
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, |
@jonas-schievink Oops! Totally my bad, I had a stale |
minified example: http://sprunge.us/fGMM (2kLoC - macro magic should be reduce this) |
Template: pub struct Gl {
pub data: [FnPtr; LEN]
}
pub struct FnPtr {
pub f: *const u8,
pub is_loaded: bool,
}
fn missing_fn_panic() -> ! {
panic!("gl function was not loaded")
}
impl FnPtr {
fn new(ptr: *const u8) -> FnPtr {
if ptr.is_null() {
FnPtr {
f: missing_fn_panic as *const u8,
is_loaded: false
}
} else {
FnPtr { f: ptr, is_loaded: true }
}
}
}
pub fn load_with(loadfn: &mut FnMut(&str) -> *const u8) -> Gl {
let mut metaloadfn = |symbol: &str, symbols: &[&str]| {
let mut ptr = loadfn(symbol);
if ptr.is_null() {
for &sym in symbols {
ptr = loadfn(sym);
if !ptr.is_null() { break; }
}
}
ptr
};
Gl { data: [ i=0;
while [[ $i -lt $j ]]; do
echo ' FnPtr::new(metaloadfn("'"function"'", &[])),';
i=$[i+1]
done >> test-slow.rs
sed -i s/LEN/$j/ test-slow.rs
echo ']}}' >> test-slow.rs |
Removing from the "launch MIR into orbit" milestone for the following reasons:
|
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. When running
So I assume the next step (which is
Is there any command I can run to explore in more details what is happening? |
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. |
Steps to reproduce:
-Zorbit
release build with the current nightly (2016-06-07
):env RUSTFLAGS="-Zorbit" rustup run nightly cargo rustc --release -- -Ztime-passes
llvm module passes
, which itself takes about 24 seconds on my machine, and then get stuck somewhere in LLVM codegencc @eddyb (I heard you like nothing more than MIR trans and LLVM bugs)
The text was updated successfully, but these errors were encountered: