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:
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:
I realize it's maybe not necessary, but it I'm forgetful and impatient and something about it just seems cool to me..... |
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 |
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:
|
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 |
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. |
I've read recently (somewhere?) the best practice is:
Code:
make -j number of cores + 1 |
Quote:
|
Instead, set the environment variable MAKEFLAGS, for example in your ~/.bashrc:
export MAKEFLAGS=-j5 To temporarily remove it, issue: unset MAKEFLAGS |
Quote:
http://delicious.com/tag/linux http://www.reddit.com/r/linux/ |
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. |
Quote:
|
All times are GMT -5. The time now is 03:08 AM. |