LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-27-2010, 10:53 PM   #1
damgar
Senior Member
 
Registered: Sep 2009
Location: dallas, tx
Distribution: Slackware - current multilib/gsb Arch
Posts: 1,949
Blog Entries: 8

Rep: Reputation: 203Reputation: 203Reputation: 203
Alias make to automatically use multiple cores?


Newbie question here. I just realized that I can tell make to use multiple cores to compile by doing
PHP Code:
make -j X 
which is just awesome on a quad core with hyperthreading (I just compiled 2.6.33-rc5 in under 5 minutes!)

I know aliases are possible, though I've never had much need. What I would like to know now, is if it would be safe to alias make to mean
PHP Code:
make -j 6 
so that by default I use 6 of the procesors when building or if there would be occasions that compiling on multiple processors would be a bad thing?

I realize it's maybe not necessary, but it I'm forgetful and impatient and something about it just seems cool to me.....
 
Old 01-27-2010, 11:26 PM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
It's not necessarily 'compiling' on multiple cores, just running multiple make commands. The performance increase would depend on how many tasks could be run synchronously ( parallel ) inside the one makefile or whether you're building multiple applications at once.

A bit of testing may help decide whether it's worth it

cheers

Last edited by kbp; 01-27-2010 at 11:26 PM. Reason: typo
 
Old 01-27-2010, 11:52 PM   #3
damgar
Senior Member
 
Registered: Sep 2009
Location: dallas, tx
Distribution: Slackware - current multilib/gsb Arch
Posts: 1,949

Original Poster
Blog Entries: 8

Rep: Reputation: 203Reputation: 203Reputation: 203
If the kernel build was any indication, it is DEFINITELY worth it, provided there are no serious risks. it was easily 3 to 4 times faster with
PHP Code:
make -j 4 
 
Old 01-28-2010, 06:31 AM   #4
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
I doubt there would be any risk.. but it depends on what else the computer is used for - other processes may suffer.

i.e if you're doing this at work then don't run it on a production server

cheers
 
Old 01-28-2010, 07:44 AM   #5
damgar
Senior Member
 
Registered: Sep 2009
Location: dallas, tx
Distribution: Slackware - current multilib/gsb Arch
Posts: 1,949

Original Poster
Blog Entries: 8

Rep: Reputation: 203Reputation: 203Reputation: 203
It's actually just my tinker-toy so while building something I'm generally just surfing around for info on whatever it is I'm doing. The OS perceives my machine to have 8 cores so even at 4 cores being used to build the kernel, top indicates under 50% CPU load which seemed like a waste to me.

Thanks for the replies.
 
Old 01-28-2010, 07:55 AM   #6
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware64 15; SlackwareARM-current (aarch64); Debian 12
Posts: 8,299
Blog Entries: 61

Rep: Reputation: Disabled
I've read recently (somewhere?) the best practice is:
Code:
make -j number of cores + 1
 
Old 01-28-2010, 08:31 AM   #7
damgar
Senior Member
 
Registered: Sep 2009
Location: dallas, tx
Distribution: Slackware - current multilib/gsb Arch
Posts: 1,949

Original Poster
Blog Entries: 8

Rep: Reputation: 203Reputation: 203Reputation: 203
Quote:
Originally Posted by brianL View Post
I've read recently (somewhere?) the best practice is:
Code:
make -j number of cores + 1
Do you have any idea where you read that? That seems counter intuitive to me, but I'd definitely be interested in the read.
 
Old 01-28-2010, 09:10 AM   #8
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
Instead, set the environment variable MAKEFLAGS, for example in your ~/.bashrc:
export MAKEFLAGS=-j5

To temporarily remove it, issue: unset MAKEFLAGS
 
Old 01-28-2010, 09:20 AM   #9
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware64 15; SlackwareARM-current (aarch64); Debian 12
Posts: 8,299
Blog Entries: 61

Rep: Reputation: Disabled
Quote:
Originally Posted by damgar View Post
Do you have any idea where you read that? That seems counter intuitive to me, but I'd definitely be interested in the read.
Sorry, can't remember exactly, but it was probably while I was browsing through one of these two:

http://delicious.com/tag/linux

http://www.reddit.com/r/linux/
 
1 members found this post helpful.
Old 01-28-2010, 02:27 PM   #10
damgar
Senior Member
 
Registered: Sep 2009
Location: dallas, tx
Distribution: Slackware - current multilib/gsb Arch
Posts: 1,949

Original Poster
Blog Entries: 8

Rep: Reputation: 203Reputation: 203Reputation: 203
I did find reference to the +1 here http://blogs.koolwal.net/2009/04/20/tip-compile-your-programs-fasters-with-multiple-processor-machines/ I'll definitely have to give that a shot with my next build.

Thanks for the tip.
 
Old 01-28-2010, 02:37 PM   #11
damgar
Senior Member
 
Registered: Sep 2009
Location: dallas, tx
Distribution: Slackware - current multilib/gsb Arch
Posts: 1,949

Original Poster
Blog Entries: 8

Rep: Reputation: 203Reputation: 203Reputation: 203
Quote:
Originally Posted by AlucardZero View Post
Instead, set the environment variable MAKEFLAGS, for example in your ~/.bashrc:
export MAKEFLAGS=-j5

To temporarily remove it, issue: unset MAKEFLAGS
On a Slack system with no .bashrc by default, can that just be added to /etc/profile?
 
  


Reply



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
Are multithreaded games in Wine really executed on multiple cores? 10110111 Linux - Software 2 01-01-2010 08:34 AM
How does the kernel handle multiple cpus/cores? riddler313 Linux - General 4 06-18-2009 08:35 AM
configuring MYSQL 5.0.67 to use multiple cores (processors) nino_of_qubic Linux - Server 3 03-31-2009 11:29 PM
LXer: Take advantage of multiple CPU cores during file compression LXer Syndicated Linux News 0 02-13-2008 08:40 PM
linux on multiple cores reslowgr Linux - Server 1 01-20-2007 03:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:44 PM.

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