GCC compilation performance under RAM starvation
Segher Boessenkool
segher@kernel.crashing.org
Sat Jun 28 04:14:06 GMT 2025
Hi!
On Sat, Jun 28, 2025 at 12:55:26PM +0900, Simon Richter wrote:
> On 28.06.25 10:54, Segher Boessenkool wrote:
> >How do you disable memory overcommit? "Just" don't run problems that
> >are bigger than you have memmory for?
>
> That is dependent on the kernel you use. On Linux, you would use the
> "vm.overcommit_memory" sysctl:
>
> - a value of 0 (default) allows overcommit, but rejects some clearly
> silly requests.
Yup. Very conservative. But also usually the best choice.
> So, something like
>
> # sysctl vm.overcommit_ratio=80
> # sysctl vm.overcommit_memory=2
>
> should guarantee you that your compiles will either run at full speed,
> or fail quickly, but as mentioned, that also applies to the rest of your
> system -- if you are using systemd or a desktop environment, all of that
> will *also* need to fit into physical RAM and cannot be swapped out even
> if unused, but these tools are written with the assumption that having a
> program loaded but not doing anything costs pretty much nothing because
> unaccessed pages will be evicted as soon as something else needs them,
> which is normally a reasonable assumption.
>
> So this solves the original problem, but is not optimal, because the
> optimal behaviour would be to swap out other programs to give GCC more
> space.
Yeah. The only real solution is to just not have too little memoory :-)
Segher
More information about the Gcc-help
mailing list