-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Middle size, 80 000 lines, project but very slow, 5 hours, compilation #65131
Comments
Please provide build instructions for that code. Running |
But I wrote
|
That gives the same error, since it just has a dependency on the crate in |
Small bug fix in the build.rs file. |
That didn't fix it |
on my debian and windows 10 build script shown: cargo:warning=Starting search config.h in.... |
made more platform specific fixes. |
I've looked into this code and likely found the problem. The bright side: it compiles in under half a minute if the errors are removed. The part of the code causing this problem is a test function that tries to test everything at once and has about 8000 lines. The function contains (as of commit ee653b1a0170) 76 borrow checker errors and the part that takes 5 hours is generating the 3-point errors for them. The time is dominated by the repeated recalculation of dominators for the function body. |
A minimized reproduction looks like this fn get_pair(_a: &mut u32, _b: &mut u32) {
}
macro_rules! x10 {
($($t:tt)*) => {
$($t)* $($t)* $($t)* $($t)* $($t)*
$($t)* $($t)* $($t)* $($t)* $($t)*
}
}
#[allow(unused_assignments)]
fn main() {
let mut x = 1;
get_pair(&mut x, &mut x);
x10!{ x10!{ x10!{ if x > 0 { x += 2 } else { x += 1 } } } }
} On my laptop this code requires about 25 seconds to print the error for the 1000 |
This looks like the only place calculating dominators from the MIR body every time instead of using the ones stored on the `MirBorrowckCtxt`. For example, in rust-lang#65131 a big generated function with a number of borrowck errors takes a few hours(!) recalculating the dominators while explaining the errors. I don't know enough about this part of rustc codebase to know for sure that this change is correct, but no tests seem to fail as a result of this change in local testing.
On the bright side, waiting 5 hours for borrowck errors is still faster than trying to debug a memory corruption in a language without borrowck. 😜 (edit: lol, why so serious, this was meant to be humorous and not a complaint about Rust…) |
… r=nagisa use precalculated dominators in explain_borrow This looks like the only place calculating dominators from the MIR body every time instead of using the ones stored on the `MirBorrowckCtxt`. For example, in #65131 a big generated function with a number of borrowck errors takes a few hours(!) recalculating the dominators while explaining the errors. I don't know enough about this part of rustc codebase to know for sure that this change is correct, but no tests seem to fail as a result of this change in local testing.
This looks like the only place calculating dominators from the MIR body every time instead of using the ones stored on the `MirBorrowckCtxt`. For example, in rust-lang#65131 a big generated function with a number of borrowck errors takes a few hours(!) recalculating the dominators while explaining the errors. I don't know enough about this part of rustc codebase to know for sure that this change is correct, but no tests seem to fail as a result of this change in local testing.
Add tests for rust-lang#58319 and rust-lang#65131 Fixes rust-lang#58319 and fixes rust-lang#65131
Rollup of 16 pull requests Successful merges: - rust-lang#65097 (Make std::sync::Arc compatible with ThreadSanitizer) - rust-lang#69033 (Use generator resume arguments in the async/await lowering) - rust-lang#69997 (add `Option::{zip,zip_with}` methods under "option_zip" gate) - rust-lang#70038 (Remove the call that makes miri fail) - rust-lang#70058 (can_begin_literal_maybe_minus: `true` on `"-"? lit` NTs.) - rust-lang#70111 (BTreeMap: remove shared root) - rust-lang#70139 (add delay_span_bug to TransmuteSizeDiff, just to be sure) - rust-lang#70165 (Remove the erase regions MIR transform) - rust-lang#70166 (Derive PartialEq, Eq and Hash for RangeInclusive) - rust-lang#70176 (Add tests for rust-lang#58319 and rust-lang#65131) - rust-lang#70177 (Fix oudated comment for NamedRegionMap) - rust-lang#70184 (expand_include: set `.directory` to dir of included file.) - rust-lang#70187 (more clippy fixes) - rust-lang#70188 (Clean up E0439 explanation) - rust-lang#70189 (Abi::is_signed: assert that we are a Scalar) - rust-lang#70194 (#[must_use] on split_off()) Failed merges: r? @ghost
This code is the MAVLink protocol handler, and generated by one of the MAVLink specification. It is C/Rust mixed project, so to compile it you will need Rust , CC an any C compiler.
To check how slow rustc is, check this out , and run cargo test in the GroundControl/demo dir
Exactly this project is compiled with error, cause the borrow checker complains in one place.
But anyway, the problem is that compilation is unacceptably slow.
Description
/GroundControl/lib generated API
/GroundControl/demo/src/use_case is generated sample of using generated API
/GroundControl/demo/src/test the test
I generate variation of this project, with same functionality, in C, C++, C#.... They are the compiled in seconds !
What wrong with my Rust project? How can I speed up compilation?
My PC
Intel I7-7700K
RAM 32G
SSD Samsung 970 PRO
cargo -V
cargo 1.39.0-nightly (ab6fa8908 2019-09-25)
rustc -V
rustc 1.40.0-nightly (22bc9e1 2019-09-30)
The text was updated successfully, but these errors were encountered: