0

Introduction to the Command Line (For information about this book, see Free Software Foundation Shop):

-j3 tells make to try to run 3 compilation processes simultaneously, which will allow you to utilize processor resources better if you have a dual-core or bigger machine. The number after -j is arbitrary, but a good rule of thumb is the number of processor cores plus one.

Q:

Why does it say that it is better to run such an amount (the number of processor cores plus one) of compilation processes simultaneously, instead of exactly the number of processor cores or some other number?

jps
  • 20,041
  • 15
  • 75
  • 79
shynur
  • 334
  • 10
  • 1
    There's extended discussion here: https://stackoverflow.com/questions/2499070/gnu-make-should-the-number-of-jobs-equal-the-number-of-cpu-cores-in-a-system. Generally this +1 is meant to mitigate time spent waiting for IO, but your mileage will vary depending on exect nature of project being built. – orhtej2 Mar 25 '23 at 14:38
  • That was also no doubt written back when hard disks were rotating and much slower than today's SSD or NVMe storage, so builds could be expected to spend more time waiting for data to load from the disk. But there's simply no way to give a general result that works best for everyone. For example, compiling C code is much simpler than compiling C++ code, which is much simpler than compiling Rust code (for example). So the percentage of build time spent doing CPU-intensive compiling of Rust, versus waiting for disk or something, will be much greater than C. – MadScientist Mar 25 '23 at 17:12

0 Answers0