-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Can't compile huge struct #81278
Comments
When compiling with a local rustc with debug assertions enabled, I got an earlier panic:
|
Cargo.toml for the repro: [package]
name = "issue81278"
version = "0.1.0"
authors = []
edition = "2018"
[dependencies]
chrono = { version = "0.4.19", features = ["serde"] }
serde = { version = "1.0.120", features = ["derive"] }
rust_decimal = "1.9.0" |
I can't reproduce this locally with stable or nightly builds installed with rustup, but I can with stage 1 build (34b3d41). |
This test case generates almost 8GB of incremental cache data, while the current implementation appears to support only 4GB due to the use of u32 for file offsets. The deeply nested closures in PartialOrd would be my first suspect after looking at the logs and either way it seems like a low hanging fruit in terms of possible improvement. @dotdash is this something you are planning to change maybe? |
Shouldn't this cause "add with overflow" etc. errors in the compiler? Or do we also explicitly allow overflows/underflows when computing file offsets? |
With changes from #81384 that remove problematic closures from PartialOrd, the size of incremental directory is reduced from ~8GB to ~2MB.
There is a debug assertion plus an unchecked |
Fix derived PartialOrd operators The derived implementation of `partial_cmp` compares matching fields one by one, stopping the computation when the result of a comparison is not equal to `Some(Equal)`. On the other hand the derived implementation for `lt`, `le`, `gt` and `ge` continues the computation when the result of a field comparison is `None`, consequently those operators are not transitive and inconsistent with `partial_cmp`. Fix the inconsistency by using the default implementation that fall-backs to the `partial_cmp`. This also avoids creating very deeply nested closures that were quite costly to compile. Fixes rust-lang#81373. Helps with rust-lang#81278, rust-lang#80118.
The nightly-2021-02-10 is the first build that avoids the issue. The compilation time is now ~1s rather than >60s (I was testing with all dependencies removed, and NaiveDateTime & Decimal fields replaced with u64, since they weren't essential part of the issue). The original problem remains. @rustbot modify labels +A-incr-comp |
Code
Meta
rustc --version --verbose
:Error output
Backtrace
The text was updated successfully, but these errors were encountered: