Rustc build memory requirement


#1

Currently README says “Rust currently needs between 600MiB and 1.5GiB of RAM to build”, but it seems outdated.

I clearly remembered building Rust on 2 GB host, so I recently purchased Scaleway 1-S VPS which provides 2 GB memory. HEAD build swapped and eventually got killed.

So 1. what is the current build memory requirement? 2. Is it desirable to keep this under 2 GB? (I think it is.)


#2

If build requirements are to be standardized, I think that an amount of memory per CPU core would make more sense than an absolute amount of memory, due to the fact that current build systems (including cargo) use a process-based parallelization approach whose RAM requirements scale ~linearly with the amount of processes in flight.

The de facto standard for mid-end consumer machines (i.e. those with an Intel iSomething in it) is 2GB/core, that could be a good baseline. But if the 1GB/core that you are requesting is feasible in a straightforward way, it would be helpful for more resource-constrained environments, such as cheap cloud VMs, embedded chips, or low-end computers.


#3

I believe I’ve seen a single rustc process using >4GB (for librustc in incremental).

I wonder if the compiler-performance working group could track RAM usage as well as CPU…


#4

Is there a way to restrict rustbuild to a single core in order to avoid running out of memory?


#5

Using GNU time, I measured 2.7 GB usage for clean build on x86_64-linux.