[SOLVED] How to use -j option the right way when compiling with make
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How to use -j option the right way when compiling with make
I am reading "O'Reilly Linux Kernel in a Nutshell" book and came across this: https://i.imgur.com/uVJhpae.png
they say that the -j option should be the double of your cpu cores.
can you please confirm if this information is true?
In gentoo handbook they say that it should one unit should be 2GB of ram, so for example if you have 4GB of ram, you should set -j2, for 8GB, -j4 and so on. https://i.imgur.com/qRs6uXL.png
Those are recommendations. All of them are sensible. The definitive documentation for GNU make is the GNU Make Manual. It has following to say:
Quote:
When the system is heavily loaded, you will probably want to run fewer jobs than when it is lightly loaded. You can use the ‘-l’ option to tell make to limit the number of jobs to run at once, based on the load average.
It depends on the code you want to compile (and how do you want to compile).
In general as a very first step you can say -j number should be the number of cores of your CPU. But that is only a very rough estimate.
Probably better to choose something around 2*N (n=number of cores), that will give usually faster result (and also bigger numbers will not help any more), but as it was mentioned it may depend on the available memory too (and the code you want to compile and the flags you use for compilation).
From the other hand your can safely try to increase that number, your box will never use more than the available RAM.
And also you can decide, if you still want to use your box (during compilation) or you want to complete that make as fast as it can do.
It depends on the code you want to compile (and how do you want to compile).
In general as a very first step you can say -j number should be the number of cores of your CPU. But that is only a very rough estimate.
Probably better to choose something around 2*N (n=number of cores), that will give usually faster result (and also bigger numbers will not help any more), but as it was mentioned it may depend on the available memory too (and the code you want to compile and the flags you use for compilation).
From the other hand your can safely try to increase that number, your box will never use more than the available RAM.
And also you can decide, if you still want to use your box (during compilation) or you want to complete that make as fast as it can do.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.