Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Gentoo General Compilation Tips & Tricks
View unanswered posts
View posts from last 24 hours

 
This topic is locked: you cannot edit posts or make replies.    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
atatut
n00b
n00b


Joined: 27 Jun 2007
Posts: 49

PostPosted: Sat Jul 07, 2007 5:47 pm    Post subject: Gentoo General Compilation Tips & Tricks Reply with quote

Hi,

Do you have the feeling your computer could do much more when compiling?
Does the "top" then press "1" command show that your new CPU with lot of cores sleeps much of the time?

Here's a guideline to "boost" a bit your “emerge” process:

First edit your /etc/make.conf with the following:

MAKEOPTS="-j256"

Yes, this sounds crazy, 256 processes at the same time.
But have in mind that this setting will:
- not work on all of your packages, most of them will compile but some will fail stupidly. So take care to leave a commented MAKEOPTS="-jx" where “x” is depending on the number of cpus/cores +1. Even more, some won’t compile at all but with a safe MAKEOPTS="-j1" like gnome-panel. So have a /etc/make.conf like this:

#MAKEOPTS=”-j1” #FOR FRAGILE PACKAGES that won’t compile with some other MAKEOPTS
#MAKEOPTS=”-jx” #FOR PACKAGES that won’t compile with some crazy MAKEOPTS or when your system lacks the RAM it deserves
MAKEOPTS=”-j256” #Optimized MAKEOPTS for systems with lot of cores and RAM

- eat a lot of RAM as this setting will basically launch the maximum processes for compilation allowed by the package being emerged.
- Make your computer unable to compile fast and start using the swap if for example you’ve booted your system in XEN and allowed your DOMAIN0 to only use the standard 256M in your /boot/grub/grub.conf. So before you correct your configuration within your XEN kernel, just make sure you reboot your computer with your /boot/grub/grub.conf altered so that your DOMAIN0 has almost all the physical RAM available. Don’t worry, once you’re sure all your packages are configured and compiled with the good USE flags you’ll just have to revert the DOMAIN0 RAM to the standard 256M. But just take the time to perfectly prepare your XEN system before you start installing 2000 VM, leaving 512M of RAM available to be able to start your test DOMAINU should be enough.

You will notice that even with that “crazy” MAKEOPTS you won’t be able to use your cores to the max. With the latest Xeon I was just able to make each one of my 8 cores work at 27%, having all of my cores sleeping at 73%!!! Maybe some packages may be corrected to allow more processes to be launched at the same time during compilation. If your system if brand new, just make sure you have at least 4GB of RAM on your system and then your may use this MAKEOPTS with no fear.

As always, linux gurus are strongly invited to share their knowledge on this case, so that newbie’s have the whole picture in mind before they even start about thinking purchasing a new system.
_________________
“When I left you, I was but the learner, now I am the master.”
Back to top
View user's profile Send private message
azuriel
Apprentice
Apprentice


Joined: 27 Feb 2005
Posts: 166

PostPosted: Sat Jul 07, 2007 6:09 pm    Post subject: Reply with quote

Hate to be a downer, but is this actually faster? Creating 256 compile threads means there's a lot more overhead, which will increase your CPU load sure but probably not translate into a faster compile. Most packages can't benefit from compiling 256 things at once, probably not even 8 things at once. Check out the distcc website:

Quote:
distcc is nearly linearly scalable for small numbers of machines: Building Linux 2.4.19 on a single 1700MHz Pentium IV machine with distcc 0.15 takes 6 minutes, 45 seconds. Using distcc across three such machines on a 100Mbps switch takes only 2 minutes, 30 seconds: 2.6x faster. The (unreachable) theoretical maximum speedup is 3.0x, so in this case distcc scales with 89% efficiency.


The key being "nearly linearly scalable for small numbers of machines" (or cores). I think efficiency drops off pretty fast.

Also, I've never had problems with reasonable MAKEOPTS settings of CPUs/cores +1...it's okayed in the handbook: http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&chap=5
_________________
Adopt an unanswered post
TJGames.org

The folly of mistaking a torrent of verbiage for a spring of capital truths, and oneself for an oracle, is inborn in us. -Valery
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 33112
Location: 56N 3W

PostPosted: Sat Jul 07, 2007 6:13 pm    Post subject: Reply with quote

atatut,

Please don't advise this.

First -j (with no number) means unlimited parallel makes.
Secondly, there is a limit which varies from package to package and machine to machine where performace gets worse with increasing MAKEOPS.

Its useful to start at -j[cores+1] and increase from there until things slow down, than back it off one.
ebuilds should protect you from parallel makes breaking builds. If you find that they don't, file a bug.

The slowdown is caused by swapping, which you can see in top and cache thrashing, which you can't see.
Cache thrashing happens when data in the CPU cache is displaced by a task switch, such as swapping between compiling one thing and another. The cache has to be reloaded when the original thread gets the CPU again.
Other than reducing the effectiveness of the cache (the number of cache misses increases) its harmless.

In short - everyone needs to test for themselves.

A word of warning ... in the limit, the system will use all of memory and swap. What happens next is not a pretty sight. The kernel will kill tasks so it can allocate memory for itself. You will probably want to reboot to ensure you have a sane state when that happens.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
atatut
n00b
n00b


Joined: 27 Jun 2007
Posts: 49

PostPosted: Sat Jul 07, 2007 6:51 pm    Post subject: Reply with quote

Well, honestly on my system I can see the change from -j9 to -j256, this allowed me to compile from liveCD to launching my VM inside Xen, in less than 12 hours. I don't know but having xorg-x11 compiled in a few seconds instead of hours is enough to make me think this -j256 does a good job. But maybe one of the gurus can set some benchmark test like trying to emerge the same harmless package on different hardware configurations so that we can start having a better idea on how to optimize everyone’s computer and kick badly some Vista ass and leave it far behind.

I'm sorry to be so bothering about looking to grab the max from my computer, even the last 0.0000000000000000001% of extra power it can give, but it’s Linux fault, not mine.
_________________
“When I left you, I was but the learner, now I am the master.”
Back to top
View user's profile Send private message
Ma3oxuct
Guru
Guru


Joined: 18 Apr 2003
Posts: 520

PostPosted: Sat Jul 07, 2007 7:04 pm    Post subject: Reply with quote

atatut wrote:
But maybe one of the gurus can set some benchmark test like trying to emerge the same harmless package on different hardware configurations so that we can start having a better idea on how to optimize everyone’s computer and kick badly some Vista ass and leave it far behind.

I'm sorry to be so bothering about looking to grab the max from my computer, even the last 0.0000000000000000001% of extra power it can give, but it’s Linux fault, not mine.


Have you tried Vista? It is the most inefficient piece of crap by far. To put things in perspective:
It uses 500 mega-bytes of RAM after a complete boot-up. (no other apps running). If you turn off all the eye candy, it eats 380 mega-byte. There is no possibility of "kicking its ass" because it is so far behind already.

My fully loaded KDE session with firefox, thunderbird, basket, konsole, konqueror, and kwrite uses 215 megs of ram. My cpu usage seldom goes above 1%. This is efficiency at its best.

The point of an operating system is to *NOT* eat all of your system's resources, but rather to leave as many resources as possible for users' applications.

I also fail to understand your comment about "it's Linux fault". Linux is not designed only for compiling software. It is designed to allow people to keep their system up and running while they use whatever software they want or need to use. Compilation is also a task that is done so that what you compile runs as efficiently as possible. It does not really matter if it takes you five more minutes to compile something so long as it allows the program you compiled to load faster, respond to input faster, handle larger loads, etc.
Back to top
View user's profile Send private message
ichbinsisyphos
Guru
Guru


Joined: 08 Dec 2006
Posts: 547

PostPosted: Sat Jul 07, 2007 7:23 pm    Post subject: Reply with quote

haha, sorry, not to offend anyone, but i had to read the thread twice to assure myself its not a joke :D
Back to top
View user's profile Send private message
Ma3oxuct
Guru
Guru


Joined: 18 Apr 2003
Posts: 520

PostPosted: Sat Jul 07, 2007 7:25 pm    Post subject: Reply with quote

ichbinsisyphos wrote:
haha, sorry, not to offend anyone, but i had to read the thread twice to assure myself its not a joke :D

:lol: I was afraid I was the only one. I was going to cite the funroll loops site, but it no longer exists :(.
Back to top
View user's profile Send private message
ichbinsisyphos
Guru
Guru


Joined: 08 Dec 2006
Posts: 547

PostPosted: Sat Jul 07, 2007 8:11 pm    Post subject: Reply with quote

to give you an idea, why it is funny, take a look here: https://forums.gentoo.org/viewtopic-t-309752.html


that aside you are of course encouraged to do your own experiments and dont stick to the recommended settings all of the time, its also a good idea to share your thoughts on the forum.

i dont think you will achieve much, when you raise the number of compilation threads that high.
here, on my core duo T2500 (2GHz Yonah), every compile (if its not currently occupied with configuration, downloading of the sources etc) always uses at least 1 core at around 100%. thats why -j2 is necessary to utilize the second core on dual core systems, and maybe another one to fill the gap when one threads ends earlier. im too lazy to benchmark, so i just stick with -j3

if your compile doesnt use single cores at around max, theres a bottleneck somewhere else i guess.
Back to top
View user's profile Send private message
ichbinsisyphos
Guru
Guru


Joined: 08 Dec 2006
Posts: 547

PostPosted: Sat Jul 07, 2007 8:51 pm    Post subject: Reply with quote

if the harddisk is the bottleneck (i dont know if this is realistic) and you have a lot of ram to waste, you should try to mount /var/tmp/portage as a ramdisk. lets see, if this way you can make better use of your 8 cores.
Code:
mount -t tmpfs tmpfs -o size=1024M,nr_inodes=1M /var/tmp/portage/

clear the directory first.
Back to top
View user's profile Send private message
azuriel
Apprentice
Apprentice


Joined: 27 Feb 2005
Posts: 166

PostPosted: Sat Jul 07, 2007 10:08 pm    Post subject: Reply with quote

Benchmarking says that compiling in a ramdisk provides negligible speedups for most people, so do your own tests before committing to it.
_________________
Adopt an unanswered post
TJGames.org

The folly of mistaking a torrent of verbiage for a spring of capital truths, and oneself for an oracle, is inborn in us. -Valery
Back to top
View user's profile Send private message
atatut
n00b
n00b


Joined: 27 Jun 2007
Posts: 49

PostPosted: Sun Jul 08, 2007 1:21 pm    Post subject: Reply with quote

What about deleting this thread and just keeping the title linked with this other thread?:

https://forums.gentoo.org/viewtopic-t-309752.html

There's much more information to talk about.

Don't worry, there's no way to offend someone when talking about knowledge, except idiots. As you can see under my nickname, I'm a noob, noobs do ask stupid things until they are noobs no more.

The idea is not attach wings to my system in the hope it will go faster, but to have the best stable system using the system resources at best, in other words; the best balance between speed and stability. And to achieve that you need to ask those who have greater knowledge, even if it means "looking stupid", otherwise if no one ever asks something we'll all end up inserting a Redmond OS cd-rom in our computer and keep clicking the "next" button.
_________________
“When I left you, I was but the learner, now I am the master.”
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 33112
Location: 56N 3W

PostPosted: Sun Jul 08, 2007 1:34 pm    Post subject: Reply with quote

atatut,

You have missed the point of the word "optimise". It means "best compromise".
Whats best for one user, one one situation will not be best for others.

Worse (for everyone) as I've already said, there is no single optimum set up for any particular user.
Gentoo does give you lots of things to play with though.

Thread locked in favour of https://forums.gentoo.org/viewtopic-t-309752.html
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Display posts from previous:   
This topic is locked: you cannot edit posts or make replies.    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum