[linux-elitists] Testing gcc-4.5.0 and clang+LLVM-trunk

Shlomi Fish shlomif at iglu.org.il
Fri Jun 18 08:58:21 PDT 2010


Executive summary: I have built and installed gcc-4.5.0 and Freecell Solver 
ran faster, after I compiled it with that compiler. I then tried clang+LLVM 
which performed very poorly.

----

I've recently gone over my LWN.net ( http://lwn.net/ ) backlog and saw this
feature about gcc-4.5.0:

http://lwn.net/Articles/387122/

It mentioned the "Link-Time Optimisation" feature (using the -flto flag) which 
piqued my interest on how well it will work for Freecell Solver ( 
http://fc-solve.berlios.de/ ). So I set out to try it out.

I downloaded gcc-4.5.0 (which took a while due to the large archive size and 
problems in finding a fast mirror), unpacked it, and read the INSTALL/ notes. 
After running the appropriate ./configure call, I typed make and waited. For 
many hours. But it built up successfully, and I was able to install it.

I used the following command, which I've stored in a shell script:

[shell]
#!/bin/bash
~/Download/unpack/prog/gcc/gcc-4.5.0/configure \
	--prefix="$HOME"/apps/prog/gcc-4.5.0
[/shell]

A better command may be:

[shell]
#!/bin/bash
~/Download/unpack/prog/gcc/gcc-4.5.0/configure \
    --prefix="$HOME"/apps/prog/gcc-4.5.0 \
    --enable-languages="c,c++"
[/shell]

After installing gcc, I patched fc-solve's CMakeLists.txt to check for the 
availability of the -flto flag and also enable it at link-time. This went 
well, and I benchmarked Freecell Solver after being compiled with it.

The end result was that it made the standard Microsoft FreeCell 32,000 boards 
benchmark take 91.0577080249786 seconds instead of 93.6305630207062 seconds , 
an improvement of over 2.5 seconds and of roughly 2.75%. (Going up to 351.43 
boards per second). So it seems like an impressive gain.

That was on my Pentium 4-2.4 GHz stationary machine running Mandriva Linux 
Cooker.

Then I set out to do the same on my newer Core Duo x86-64 laptop also running 
Mandriva Cooker. I installed gcc this time restricting the --enable-languages 
to c and c++ so it will take less time. After installing it in a prefix, I 
realised CMake could not find its -flto flag . As it turns out, it was not 
enabled because gcc-4.5.0 could not find libelf-devel. Installing it resolved 
it.

The difference there was less dramatic than on my P4 machine - about 0.5 
seconds were saved out of about 35 seconds running time. However, in general, 
I'm happy with the results.

Thanks to all the gcc developers for their hard work on making gcc better, 
including improving the performance of many programs.

----

After I forwarded a previous version of this message to the Linux-Israel 
mailing list, someone asked me if I tried LLVM and clang yet with it and then 
Diego Iastrubni has given some build instructions here:

http://www.mail-archive.com/linux-il@cs.huji.ac.il/msg58719.html

Building clang this way was straightforward, but it didn't finish before I've 
gone to sleep, and I had to keep it running at night. Then I benchmarked the 
same benchmark and it performed much worse than on gcc-4.5.0: 105.567487955093 
seconds for clan vs. 90.6 seconds for gcc.

Reading from this comment on LWN.net - http://lwn.net/Articles/391557/ :

[quote]
Actually they [= Apple] just refuse to touch anything GPLv3-related. And they 
often oversell LLVM because they compare it with years-old GNU stuff.

This is really sad because LLVM is great - it's just not as great as Apple PR 
guys claim...
[/quote]

And I can attest to it now. :-). Someone I talked with on Jabber said he 
thought that LLVM was supposed to cure all the world ailments including 
cancer. (Though a little tongue-in-cheek). However, judging from my benchmarks 
it still has a long way to go.

In any case, I should note that I noticed that the same benchmark ran a little 
faster after I cleaned up my hard disk, and also that it ran a few seconds 
faster (out of below 100) on Mandriva Cooker than on Debian Testing.

Regards,

	Shlomi Fish

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
Original Riddles - http://www.shlomifish.org/puzzles/

God considered inflicting XSLT as the tenth plague of Egypt, but then
decided against it because he thought it would be too evil.

Please reply to list if it's a mailing list post - http://shlom.in/reply .


More information about the linux-elitists mailing list