Consider recommending LLVM_PARALLEL_LINK_JOBS=1 to help with max memory usage during clang build?
Just did a few clang-9 test builds on an old 16GiB AMD FX-8350 with a Toshiba SSD on the Solus Linux distribution with LLVM_PARALLEL_LINK_JOBS=1
:
- Maximum observed memory size for a single link job was 11.5 GiB Resident
- Maximum observed memory size for a single compile job was 7.5 GiB Resident
- Common observed memory size for a single compile job was 1.5 - 5 GiB Resident
- With
LLVM_PARALLEL_LINK_JOBS=1
andmake -j3
, maximum observed memory consumption of compile jobs during build was 2GiB + 6-ish GiB + 7.5-ish GiB Resident, which pushed my 16GiB system into swap a little.
Build time notes:
make -j2
:
real 206m23.818s
user 383m30.154s
sys 6m24.131s
make -j3
:
real 162m49.967s
user 412m23.566s
sys 6m40.476s
So decent scaling in both cases (-j2 = ~86% and -j3 = ~85%).
Memory / Job count scaling notes:
I wouldn't go higher than make -j2
with LLVM_PARALLEL_LINK_JOBS=1
on a 16 GiB system if I was planning on working at the same time.
Another Solus Linux developer using an AMD R9 3900X with 64 GiB RAM and a Samsung 850 EVO SSD reported the following build times and max RAM usage with LLVM_PARALLEL_LINK_JOBS=1
:
-
make -j1
: ~190m (N/A) -
make -j4
: 68m (~20GiB) -
make -j8
: ~54m (~30GiB) -
make -j16
: ~50m (~45GiB) -
make -j24
: ~50m (~55GiB)
In summary, with LLVM_PARALLEL_LINK_JOBS=1
make -j24
is probably fine on 64GiB systems, but there might be little value in going beyond make -j8
in most cases. With 32GiB of RAM, there's definitely no point in going beyond make -j8
.