Skip to content

Commit 4e6648d

Browse files
committed
[lto] Use more conservative estimates of clang/swift memory usage.
I found experimentally that my former esimates were too low. I have found that these numbers work pretty well. rdar://24717107
1 parent 7505b6b commit 4e6648d

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

utils/build-script-impl

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,15 @@ function float_min() {
277277
function num_llvm_parallel_lto_link_jobs() {
278278
case "$(uname -s -m)" in
279279
Darwin\ x86_64)
280-
# Currently with -gline-tables-only clang is ~3.5GB on Darwin. Use
281-
# the formula GB Memory/3.5GB to get the number of parallel link
282-
# threads we can support.
283-
local NUM_MEMORY_THREADS=$(echo $(system_memory_in_bytes)/1000000000.0/3.5 | bc)
280+
# *WARNING! HUERISTIC!*
281+
#
282+
# Use the formula (GB Memory - 3)/6.0GB to get the number of
283+
# parallel link threads we can support. This gives the OS 3 GB of
284+
# room to work with.
285+
#
286+
# This is a bit conservative, but I have found that this number
287+
# prevents me from swapping on my test machine.
288+
local NUM_MEMORY_THREADS=$(echo \( $(system_memory_in_bytes)/1000000000.0 - 3.0 \) / 6.0 | bc)
284289
echo $(float_min "${NUM_MEMORY_THREADS}" "${BUILD_JOBS}")
285290
;;
286291
*)
@@ -293,10 +298,15 @@ function num_llvm_parallel_lto_link_jobs() {
293298
function num_swift_parallel_lto_link_jobs() {
294299
case "$(uname -s -m)" in
295300
Darwin\ x86_64)
296-
# Currently with -gline-tables-only swift is ~5-6GB on Darwin. Use
297-
# the formula GB Memory/6GB to get the number of parallel link
298-
# threads we can support.
299-
local NUM_MEMORY_THREADS=$(echo $(system_memory_in_bytes)/1000000000/6.0 | bc)
301+
# *WARNING! HUERISTIC!*
302+
#
303+
# Use the formula (GB Memory - 3)/8.0GB to get the number of
304+
# parallel link threads we can support. This gives the OS 3 GB of
305+
# room to work with.
306+
#
307+
# This is a bit conservative, but I have found that this number
308+
# prevents me from swapping on my test machine.
309+
local NUM_MEMORY_THREADS=$(echo \( $(system_memory_in_bytes)/1000000000 - 3.0 \) / 8.0 | bc)
300310
echo $(float_min "${NUM_MEMORY_THREADS}" "${BUILD_JOBS}")
301311
;;
302312
*)

0 commit comments

Comments
 (0)