Nov 15 2008

Compile Twice as Fast with Make

Published by at 10:19 am under DevOps,Linux

Even though GNU “make” utility retrieves a lot of information off the system it’s running on, many times I have to wait a long time to get binaries compiled. It seems “make” doesn’t always pick the best settings to compile applications. I searched how I could speed up compilation times and here are some interesting results.

build_server$ make
5m7s


I wasn’t getting the best performances out of my Linux Redhat, so I turned off the cpuspeed service. cpuspeed reduces or raises the clock speed basically to save power according to the man page. This can have a significant impact when you need to release the CPU’s full capacity: 12% faster in my case:

build_server$ /etc/init.d/cpuspeed stop
build_server$ make
4m30s


Second setting you can play with is the number of jobs “make” can run simultaneously. This is particularly interesting when compiling on multicore servers, which is most likely the case nowadays. It looks like setting the jobs to the number of cores gives the best results with the -j command option. Number of cores can be obtained with the top or cat /proc/cpuinfo commands. This is another 48% gain, making it 53,7% overall.

build_server$ make -j 4 # number of CPUs
2m22s


CI/CD is spreading fast and IT departments build and compile sometimes many times a day. It is crucial to reduce the time spent in compiling applications. These 2 tricks speed up compile times by over 50% which is pretty awesome. This test was conducted on compiling php on a Redhat distribution.


No responses yet

Comments RSS

Leave a Reply