GNU make can handle parallel tasks with a -jN argument, and it’s common to use a number of tasks N that’s between 1 and 2 times the number of hardware threads on the computer being used for the build.
E.g. on a dual-E5520 machine (2 CPUs, 4 cores per CPU, 2 threads per core), the fastest builds are made with commands between make -j16 and make -j32.
Right now i dont know much about my build server but
when i run cat /proc/cpuinfo
it shows it has 4 processor
and each info is like this
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 37
model name : Intel(R) Core(TM) i3 CPU 530 @ 2.93GHz
stepping : 2
cpu MHz : 2933.000
cache size : 4096 KB
physical id : 0
siblings : 4
core id : 0
cpu cores : 2
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 11
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm sse4_1 sse4_2 popcnt lahf_lm arat tpr_shadow vnmi flexpriority ept vpid
bogomips : 5851.87
clflush size : 64
cache_alignment : 64
address sizes : 36 bits physical, 48 bits virtual
power management:
Question:
1>so here how can i calculate N for my build?
2>what if my system can support maximum 8 threads and if i give make -j32?
3>what if i just use make then only 1 thread will be run for compilation?
You can’t hurt anything with the -j option. It is just used to tune the number of simultaneous processes that should be used by make in order to get maximum performance from your system for doing the build.
You can set it to be less than 4, with your 2 cores x 2 Hyperthreads each, if you want to have CPU time more available for other things you are doing (faster response for browsing, perhaps).
You can set it to more than 4 so that one of the processes is utilizing each of the execution units while other processors are waiting for I/O.
If you have enough memory -j32 shouldn’t hurt anything, but it won’t help either. See the comments for why you don’t want to overdo.
If there’s one software package you make all of the time you can experiment and see what setting allows it to build the fastest without hurting your interactive performance. Another way to tune is to look at top output and see at what -j multiprocessing level you are keeping the CPU utilization close to 100% most of the time.
In his Linux Kernel in a Nutshell book [1], Greg Kroah-Hartman suggest doubling the number of execution units when setting the -j option. For you that would be
-j8.[1] Linux Kernel in a Nutshell, Greg Kroah-Hartman, pg. 26. [http://www.kroah.com/lkn/%5D