-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Large ZST arrays take a looong time to compile #68010
Comments
I've tried to compile this with So I tried compiling using the compiler for the last commit (installed with
Here's what I got: Standard output (if that even matters)
Standard error
This last line:
Is emitted in here: rust/src/librustc_mir/interpret/eval_context.rs Lines 702 to 786 in 06c9fef
So I believe this is a const eval bug? |
Hm, not off the top of my head. Cc @rust-lang/wg-const-eval I take it it keeps going after that last line without outputting anything any more? Then that's just the last thing it completed, which might or might not have anything to do with the next thing it is doing. Could you use |
Okay so this is interning walking every single field of that array... and taking forever to do that, obviously. |
Letting it run a bit longer gave me an additional frame:
|
@Nemo157 How did you originally find this? Did it impact a real code you had? |
Assigning |
@LeSeulArtichaut the context was around here on discord, I was just trying to find out whether you could have a ZST array with length > |
Alright, it is fine being |
For arrays and slices we could make interning check the relocation map for relocations within the array, compute the indices which have relocations and only look at those indices. This way we don't have to walk all elements, but only those that interning cares about. Not sure what validation will do after interning is finished, maybe that'll also run forever? I thought we had some optimizations in there. Oh yea, and interning can skip any zst type in general. |
…, r=oli-obk Optimize const value interning for ZST types Interning can skip any inhabited ZST type in general. Fixes rust-lang#68010 r? @oli-obk
Test case:
I left it compiling for just over half an hour, and it sat at constant memory usage and 100% of a CPU core for the entire time. Originally tested on
rustc 1.41.0-nightly (a605441e0 2019-12-15)
.Checking through some different versions, these all take over a minute (I didn't bother sitting around for the full 30 minutes):
rustc 1.32.0 (9fda7c223 2019-01-16)
rustc 1.33.0 (2aa4c46cf 2019-02-28)
rustc 1.35.0 (3c235d560 2019-05-20)
rustc 1.40.0 (73528e339 2019-12-16)
rustc 1.42.0-nightly (859764425 2020-01-07)
Going back a little further it works and compiles in about a second on:
rustc 1.30.0 (da5f414c2 2018-10-24)
rustc 1.31.0 (abe02cefd 2018-12-04)
Going back even further it ICEs with
capacity overflow
on:rustc 1.0.0 (a59de37e9 2015-05-13) (built 2015-05-14)
rustc 1.21.0 (3b72af97e 2017-10-09)
(this may be a duplicate of one of the existing large array compile time issues, but I didn't find one it fit exactly with, especially given it worked on at least two stable releases).
The text was updated successfully, but these errors were encountered: