LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 05-29-2021, 10:37 AM   #1
George528
Member
 
Registered: May 2021
Location: Moldova
Distribution: Arch, Debian
Posts: 95

Rep: Reputation: 2
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 LFS book, they said that the -j number should be the number of cores of your CPU.
https://i.imgur.com/tqoVxHt.png


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

Which information is true? i am so confused.

Last edited by George528; 05-29-2021 at 10:41 AM.
 
Old 05-29-2021, 10:43 AM   #2
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,677

Rep: Reputation: Disabled
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.

Last edited by shruggy; 05-29-2021 at 10:48 AM.
 
Old 05-29-2021, 11:04 AM   #3
George528
Member
 
Registered: May 2021
Location: Moldova
Distribution: Arch, Debian
Posts: 95

Original Poster
Rep: Reputation: 2
Quote:
Originally Posted by shruggy View Post
Those are recommendations. All of them are sensible. The definitive documentation for GNU make is the GNU Make Manual. It has following to say:
i see, thanks for clearing this out
 
Old 05-29-2021, 01:37 PM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,997

Rep: Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338
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.
 
Old 05-30-2021, 02:56 AM   #5
George528
Member
 
Registered: May 2021
Location: Moldova
Distribution: Arch, Debian
Posts: 95

Original Poster
Rep: Reputation: 2
Quote:
Originally Posted by pan64 View Post
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.
thanks! i will mark this solved
 
  


Reply

Tags
compile, jobs, make



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] -current, often got [make] <defunct> when compiling with -j option Linux.tar.gz Slackware - ARM 3 10-11-2018 12:27 AM
[SOLVED] [PATCH] xcmddc does not handle --identify option right way. yars Slackware 1 01-19-2016 03:52 PM
Does it really make a difference to use make -jK instead only "make" while compiling? angel'le Linux - General 1 04-26-2014 01:14 AM
screen / screenrc: how to use the right / ctrl arrow to go left and right in windows? frenchn00b Linux - General 6 11-10-2009 01:11 PM
LXer: Setting time the right way, the Linux way LXer Syndicated Linux News 0 10-03-2007 10:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration