Re: Rust build huge memory consumption

From: Matthew Seaman <matthew_at_FreeBSD.org>
Date: Wed, 25 Oct 2023 07:18:02 UTC
On 25/10/2023 07:47, Xavier Humbert wrote:
> Le 10/25/23 08:46, Cy Schubert a écrit :
>> In message <09a4bfb8-ba61-4e05-b646-973104337f77@groumpf.org>, Xavier
>> Humbert w
>> rites:
>>> Hi,
>>>
>>> When building rust, all memory is eaten, leading to OOM killing almost
>>> everything, eventually failing, and leading to an unstable system.
>>>
>>> Is there a way to tell the compiler to avoid this behaviour ?
>> How much RAM does your machine have? How many CPU cores/threads does it
>> have?
>>
> I have 16 GB RAM, and 4 cores

I've managed to build rust on a smaller machine than that.  I find that 
the following helps:


   * Stopping rust and some other large ports building on tmpfs

     TMPFS_BLACKLIST='rust gcc* llvm* texlive-texmf'
     TMPFS_BLACKLIST_TMPDIR=/usr/local/poudriere/data/cache/tmp
     USE_TMPFS=yes
     TMPFS_LIMIT=4

   * Building rust separately from other ports, and then doing
     incremental builds for the rest of the ports

     % poudriere bulk -j stable14amd64 -b latest lang/rust

rust is annoying in that it doesn't respect the ALLOW_MAKE_JOBS setting, 
and will launch multiple threads of compilation irespective of it, which 
really doesn't help on a memory / CPU onstrained system.  Even so, 
separating out rust for individual compilation means poudriere runs that 
are a complete faff.

You can't just kick off an incremental rebuild of ports and leave it to 
do its thing, but have to babysit the process and keep building certain 
ports specially.  It wouldn't be so bad, but it seems that just about 
any trivial activity in the ports tree means poudriere will insist that 
rust needs rebuilding.

	Cheers,

	Matthew