View previous topic :: View next topic |
Author |
Message |
Guenther Brunthaler Apprentice
Joined: 22 Jul 2006 Posts: 217 Location: Vienna
|
Posted: Tue Sep 05, 2006 2:28 pm Post subject: Is your new GCC 4 rotten slow compared to GCC 3? |
|
|
Hi all,
After all I've heard, the new GCC4 generates better code than GCC3, but it also requires considerably more memory to work.
This can become a problem if you have a machine which has less RAM installed than GCC4 is using (some reports say it's using more than 2 GB for compiling a single C++ file in extreme cases).
In such situations, the reason why your machine is becoming so darn slow, is because of permanent swapping, also known as "thrashing".
In such cases, it is not uncommon for the total compilation speed to go down by a factor of 1000. (That is because the CPU(s) of your system can't do anything most of the time; they just wait for data from the hard disk nearly all the time.)
One possibility to fix the problem is of course to add more RAM.
But in many cases there is also an easy and cheap alternative to that:
If you were following the standard Gentoo setup guide when you installed your system, you might have the following entry in your /etc/make.conf:
MAKEOPTS="-j2"
Change this to
MAKEOPTS="-j1"
and your GCC will only need half the memory of before most of the time!
If you are lucky, then the amount of your installed RAM will again be enough to avoid the thrashing. And even if not, it will certainly thrash less.
How does it work?
The -j option in $MAKEOPTS specifies the number of parallel compilations that can take place at the same time.
-j2 thus means that 2 GCC4 processes will be compiling different source files when make has to compile a bunch of source files.
If you have memory enough, this is fine because both GCC's can share their code, and if one of the GCCs is waiting for more data from the disk, the other can continue compiling; thus minimizing unused processor power.
But if you have too little memory, the disk trashing which occurs will nullify any such advantage anyway, so it's better to only run a single GCC.
Note however, that decreasing the number of parallel compilations is probably not a good idea when using the distributed GCC package ("distcc"). It this case you must ensure somehow else that no more than one GCC4 process is run on a single machine (which too little RAM) by distcc. |
|
Back to top |
|
|
irondog l33t
Joined: 07 Jul 2003 Posts: 715 Location: Voor mijn TV. Achter mijn pc.
|
Posted: Tue Sep 05, 2006 8:19 pm Post subject: |
|
|
Remember, that even when GCC4.1 isn't "trashing" it's much slower than GCC3.x. _________________ Alle dingen moeten onzin zijn. |
|
Back to top |
|
|
uweklosa Tux's lil' helper
Joined: 18 Feb 2005 Posts: 105
|
Posted: Tue Sep 05, 2006 8:37 pm Post subject: |
|
|
I don't have this impression on my system. |
|
Back to top |
|
|
irondog l33t
Joined: 07 Jul 2003 Posts: 715 Location: Voor mijn TV. Achter mijn pc.
|
Posted: Tue Sep 05, 2006 9:02 pm Post subject: |
|
|
Maybe much is overdone. I remember I benched gcc 3.x against 4.0 and 4.0 against 4.1. In both cases the newer versions were slower. _________________ Alle dingen moeten onzin zijn. |
|
Back to top |
|
|
zxy Veteran
Joined: 06 Jan 2006 Posts: 1160 Location: in bed in front of the computer
|
Posted: Wed Sep 06, 2006 10:01 pm Post subject: |
|
|
Does gcc use /var/tmp/portage/..... for temp files (if it uses temp files at all) or is there some other folder.
I usualy mount /var/tmp/portage to tmpfs before compiling, so disk usage is (usualy) only while decompressing tar files. But sometimes I can still see light go on during compile - it might still be ccache. _________________ Nature does not hurry, yet everything is accomplished.
Lao Tzu |
|
Back to top |
|
|
Maedhros Bodhisattva
Joined: 14 Apr 2004 Posts: 5511 Location: Durham, UK
|
Posted: Thu Sep 07, 2006 9:59 am Post subject: |
|
|
zxy wrote: | Does gcc use /var/tmp/portage/..... for temp files (if it uses temp files at all) or is there some other folder. |
Well, that's where portage builds the sources, so the object files are put there after being compiled. Wine regularly uses more than 1GB in /var/tmp/portage when compiling here though, so unless you have ridiculous amounts of ram you might be hitting swap anyway. _________________ No-one's more important than the earthworm. |
|
Back to top |
|
|
agent_jdh Veteran
Joined: 08 Aug 2002 Posts: 1783 Location: Scotland
|
Posted: Thu Sep 07, 2006 10:17 am Post subject: |
|
|
I've only got 512MB here and gcc-4.x appears quicker than the 3.x series. Just my 2p. Using makeopts=-j2 afaik. _________________ Jingle Jangle Jewellery |
|
Back to top |
|
|
Guenther Brunthaler Apprentice
Joined: 22 Jul 2006 Posts: 217 Location: Vienna
|
Posted: Thu Sep 07, 2006 2:11 pm Post subject: |
|
|
agent_jdh wrote: | I've only got 512MB here and gcc-4.x appears quicker than the 3.x series. Just my 2p. Using makeopts=-j2 afaik. |
I would really like to use GCC4 because of its better code generator.
But then - you've also read those reports about the extreme hunger for RAM by GCC4, haven't you?
However, it certainly depends on the source file which is being compiled.
C source files won't need too much memory, no matter which compiler is used.
But C++ source files are a different story.
I remember watching extreme slow compilation progress when the QT libraries have been recompiled (although I was still using the 3.4.6 compiler).
Which means GNOME users might be happier than KDE users with GCC4.
So may I ask: Did you also emerge the QT libraries? (And watch them being compiled.)
If you didn't, it may be a good explanation for those conflicting reports ("faster" vs. "my swap file goes through the roof"). |
|
Back to top |
|
|
syg00 l33t
Joined: 23 Aug 2004 Posts: 907 Location: Brisbane, AUS
|
Posted: Thu Sep 07, 2006 2:21 pm Post subject: |
|
|
zxy wrote: | I usualy mount /var/tmp/portage to tmpfs before compiling, so disk usage is (usualy) only while decompressing tar files. | Mmmm - tmpfs uses page cache. Page cache is subject to swapping.
Anybody who is memory constrained and worried about the subject of this thread, may like to keep this in mind. _________________ Got a good backup ??? - any advice offered presumes you have. |
|
Back to top |
|
|
agent_jdh Veteran
Joined: 08 Aug 2002 Posts: 1783 Location: Scotland
|
Posted: Thu Sep 07, 2006 2:43 pm Post subject: |
|
|
Guenther Brunthaler wrote: | agent_jdh wrote: | I've only got 512MB here and gcc-4.x appears quicker than the 3.x series. Just my 2p. Using makeopts=-j2 afaik. |
I would really like to use GCC4 because of its better code generator.
But then - you've also read those reports about the extreme hunger for RAM by GCC4, haven't you?
However, it certainly depends on the source file which is being compiled.
C source files won't need too much memory, no matter which compiler is used.
But C++ source files are a different story.
I remember watching extreme slow compilation progress when the QT libraries have been recompiled (although I was still using the 3.4.6 compiler).
Which means GNOME users might be happier than KDE users with GCC4.
So may I ask: Did you also emerge the QT libraries? (And watch them being compiled.)
If you didn't, it may be a good explanation for those conflicting reports ("faster" vs. "my swap file goes through the roof"). |
QT/KDE here. Certainly didn't notice any significant difference - it still takes ages to compile, just like it did with gcc-3.x! An emerge -e world is actually a bit faster now. _________________ Jingle Jangle Jewellery |
|
Back to top |
|
|
Guenther Brunthaler Apprentice
Joined: 22 Jul 2006 Posts: 217 Location: Vienna
|
Posted: Thu Sep 07, 2006 2:58 pm Post subject: |
|
|
agent_jdh wrote: | QT/KDE here. Certainly didn't notice any significant difference - it still takes ages to compile, just like it did |
Fine!
Then I'll also dare it and recompile everything for GCC4 on occasion.
Except on that 128 MB notebook. |
|
Back to top |
|
|
devsk Advocate
Joined: 24 Oct 2003 Posts: 2995 Location: Bay Area, CA
|
Posted: Thu Sep 07, 2006 6:54 pm Post subject: |
|
|
zxy wrote: | Does gcc use /var/tmp/portage/..... for temp files (if it uses temp files at all) or is there some other folder.
| gcc doesn't create temp files if -pipe is used. So, that's one sure way of bypassing disk during compiles. Always have -pipe in your CFLAGS/CXXFLAGS. (only reason you would not want to have -pipe in your CFLAGS is if you are not using GNU assembler, which nobody on linux will do) |
|
Back to top |
|
|
|