I’m not quite sure how I ever missed this, but the make
command has as parameter that controls how many simultaneous jobs it can run at once. The default “compile from source” flow looks like this.
$ make clean $ ./configure $ make $ make install
Step 1, 2 and 4 can’t really be speed up (I think?), but the step that actually builds the binaries/libraries/… is make
, and with the -j
flag you can tell it how many jobs to run at the same time.
For instance, if you have 4 CPU cores, you can let make
run 4 threads at once.
$ make clean $ ./configure $ make -j 4 $ make install
If you just specify -j
, without a number, it’ll spawn an infinite number of jobs, but that may not be exactly what you want. It’ll be safer to limit this to the amount of cores you have available (and that aren’t currently maxed out).
I’ll try to remember this one, next to my other ground rules for compiling from source.
For instance, when building PHP from source, a normal make
took 14 minutes, a make -j 2
(since I have 2 cores available) took 7.5 minutes. That’s a clear win in time right there!