Tuesday 21 February 2017

Speed up your Make

How to speed up your make process on a multi core machine.

The Make Process


Whenever you are using make without arguments just a single core of your machine is used. A single process is created, which runs on one core.

No matter what kind of insanely awesome working computer you might have you are simply going to get the performance of a single core unless you create multiple process.

The make command allows you to specify the number of processes using the -j argument




Dual Core Machine Example


Example I am using a Dual-Core Machine, (If you haven't guessed by now. I use ancient hardware).
I would use 2 processes and thus would fire the command

make -j2

Merely creating two process doesn't actually guarantee that the processes will execute on different cores, it depends on CPU scheduling but you would improve the chances of the processes running parallel. If you aren't doing something heavy, these should be allocated on separate cores allowing you a nice speedup.

Next time make your make work faster!

Edit: Right now I just fired make -j2 and am actually repenting. Since the make was taking too long I decide to watch an episode of sitcom. Turns out both my cores are occupied. Video playback is now choppy and comes with grayscale effect.
Moral : Leave at least one core free, unless you want the job done immediately.

No comments:

Post a Comment