-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Codegen for a large static array uses a lot of memory #30083
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
200MB is possibly slightly excessive... but it's naturally going to take a lot of memory to generate a 30MB object file. |
Wait, no, I miscalculated; it's actually a 130MB object file. |
This is more of an LLVM issue, as I believe that we have to generate essentially Note that this isn't an issue for Looking at the issue from users.rust-lang.org, it should be able to use a zeroinitializer, as the value is all-zeros. However, it doesn't for some reason. Investigation suggests that it doesn't for element types larger than a word (so |
It would be nice if LLVM was doing RLE for these kinds of things. |
One issue shown by #35154 is that very large arrays can cause ICEs due to us trying to create absurdly-large vectors to hand to LLVM for constants. |
Triage:
That said, I think this issue could use a better title, because I would intuitively expect a large static array to use at least a linear-ish amount of memory when compiling. What is the specific issue that we should address? (eddyb uses the term "RLE" above, which I have no expansion for.) |
@bstrie "trans(lation)" is the old jargon for "codegen", maybe I should've retroactively replaced all of the mentions of it to avoid confusion. RLE means "Run-length encoding", one of the common primitives of compression algorithms. In this specific case, LLVM could represent constant blocks of data as N repeats of (smaller) block, which would always allow us to represent
It's not a bad intuition, but at no point do you actually have a linear amount of entropy, you can represent the array as " |
Following 2 lines of Rust code can use more than 200 MB of memory to compile.
Reported on users.rust-lang.org post. See also #23600.
The text was updated successfully, but these errors were encountered: