Speedup GNU make build and compilation process
Building/compiling libraries or projects frequently with GNU make takes long time. To speed up these builds you can use make -jN where N is the number of parallel builds. For example:
will make 4 parallel builds.
Hardware considerations
Of course, you can’t do something like
This is the best way to get your computer hangs !!! You must check your hardware CPU informations. How many processors (cores) you have (including multi-threading):
You can also use dmidecode :
here you got two processors (2 times Core Count) with 8 cores. You can also use lspcu command:
System considerations
Once you get your number of cores, we must keep a responsive system. We use -l options of make -l [load], –load-average[=load] {Specifies that no new jobs (commands) should be started if there are others jobs running and the load average is at least} load
To get a full saturation of the processors without hanging your system, export the following environment variable MAKEFLAGS:
Or:
It means here that the load average does not exceed number of cores.
Persistent settings
To get these settings persistent, just add in your .bashrc or .bash_profile:
At last a commandline example
I you dont want particular settings , just use commandline:
Remarks
You can usually get away with having twice as many jobs as you do CPUs if you have a decent amount of RAM. If your CPU supports hyper-threading then you can often get by with twice as many again. That’s 128 jobs if you have a 32 dual core machine with hyper-threading! (Thanks to Andrew Stormont for his contribution)
If you found this post or this website helpful and would like to support our work, please consider making a donation. Thank you!
Help UsArticles in the same category
- Time a task: time
- SVN -- How to ignore file or directory in subversion?
- SVN -- Branch, Branching subversion howto
- Speedup GNU make build and compilation process
- phpMyAdmin: Search and Replace in MySQL database
- Linux How to delete or remove printer from command line
- Linux How to connect to Windows with remote desktop RDP in CentOS 7 / RedHat 7
- Intel compilation for MIC architecture KNL Knights Landing
- How to setup SSH timeout in shell script ?
- How to make a denial of a service with fork functions in BASH ?
- How to encrypt/decrypt a file or directory in Linux?
- How to diff remote files using ssh ?
- How to Convert Text File From ISO-8859-15 to UTF-8 Encoding
- How to change the MAC address on Linux
- Got permission denied while trying to connect to the Docker daemon socket
- GNU compilation for MIC architecture KNL Knights Landing
- Generating a self-signed certificate using OpenSSL with Linux CentOs/RedHat for Apache/httpd
- Find out biggest cpu/memory consuming processes with ps command
- Find list of options that python was compiled with
- Download music and videos .mp3, .wma, .avi, .mpg , divx with google
- Crontab : Scheduling Tasks
- Comment changer son adresse MAC sous Linux
- Check/find version of numpy i'm using
- Archiving and compressing data files tar
- Linux - Tip of the day