-
Notifications
You must be signed in to change notification settings - Fork 12.1k
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
rustc
runs out of memory while trying to compile a large static (lazy_static!) HashMap
#61513
Comments
Hey I'm doing almost your exact thing. I solved it by using a phf. It still crashed when I had all the Unicode entries added in one file, so I had the data in another file and read it from there in a loop while adding entries. |
GCC is not a Rust compiler, so that comparison doesn't really work. It's also a single function containing 277000 lines, so it's not exactly surprising that it uses a lot of time and memory to build. That said, this should of course not blow up as drastically. According to Even if this will be fixed, I can not recommend compiling this much generated code. A better solution might be to prepare the data in a build script and including it using |
@jonas-schievink This should be fixed. Compiling in data like this is routine. I do not want to use a data file or Compiling large amounts of data into a program as an optimization is common to do in C and C++. Machine learning, video game graphics, etc. This is essential for a systems programming language to be able to do. @JuanPotato Are there run-time costs? It's interesting how close the projects are, but I just made |
I'm not sure about runtime costs, you would have to look up more about phf (perfect hash functions) for that. |
I tried using PHF but it similarly uses all my memory and crashes. Didn't try using |
Yeah I had the same issue and ended up with my build.rs. My friend says phf might have better performance than a standard hashmap. I'll try a benchmark sometime today |
That's exactly what |
@hellow554 Without deserializing. |
I've just got bitten by this issue when building a Rust file with ~26k |
My machine has 48GB of memory, yet still can't compile the example project, which creates a static hash map at compile time.
I tried both nightly and stable, same thing.
The input source code is only 19M, only containing u32s and strings. This shouldn't happen, GCC could do this no problem.
Project crash.zip
The text was updated successfully, but these errors were encountered: