@@ -277,10 +277,15 @@ function float_min() {
277
277
function num_llvm_parallel_lto_link_jobs() {
278
278
case " $( uname -s -m) " in
279
279
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)
284
289
echo $( float_min " ${NUM_MEMORY_THREADS} " " ${BUILD_JOBS} " )
285
290
;;
286
291
* )
@@ -293,10 +298,15 @@ function num_llvm_parallel_lto_link_jobs() {
293
298
function num_swift_parallel_lto_link_jobs() {
294
299
case " $( uname -s -m) " in
295
300
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)
300
310
echo $( float_min " ${NUM_MEMORY_THREADS} " " ${BUILD_JOBS} " )
301
311
;;
302
312
* )
0 commit comments