Tiny Core Linux

Tiny Core Base => Raspberry Pi => Topic started by: bmarkus on December 07, 2013, 02:15:13 PM

Title: LTO benchmark
Post by: bmarkus on December 07, 2013, 02:15:13 PM
LTO (Link Time Optimization) is a GCC feature to provide additional optimization on the traditional ones. I made an ad-hoc benchmarking of the new Linaro 4.8 2013.11 (GCC 4.8.3 pre) and binutils 2.4 building common archivers, measuring performance of LTO and compared to BusyBox equivalent too.

Size gain of executable files resulted by LTO is between 0 and 8% depending on application. Compilation time is increasing significantly, by 60-100% or even more. What is about performance? There are no significant change except mainstream tar when LTO optimized version is 100% faster creating tar file.

The most interesting is the BusyBox comparision. In most cases it has the same or better performance than the mainstream equivalent except gzip. I was supprized, expected much worst result for BusyBox.

Second table shows runtime in mm:ss

(http://www.hasix.org/files/rpi/ltotst1.png)

It is a quick ad-hoc test, but a good indication what you can expect from LTO. If you are compiling a program, it is worth to try LTO if you have GCC 4.7.x or 4.8.x (expecting toolchain supports LTO). Just add -flto to compiler flags. Result must be similar on x86

Title: Re: LTO benchmark
Post by: Juanito on December 07, 2013, 10:42:15 PM
Is there a difference in size if you use lto like this:
Code: [Select]
CC="gcc -flto -fuse-linker-plugin -march=i486 -mtune=i686 -Os -pipe" CXX="g++ -flto -fuse-linker-plugin -march=i486 -mtune=i686 -Os -pipe -fno-exceptions -fno-rtti" ./configure --prefix=/usr/loca
Note that you usually need something like this before running "make":
Code: [Select]
find . -name Makefile -type f -exec sed -i 's/-O2/ /g' {} \;
Title: Re: LTO benchmark
Post by: bmarkus on December 08, 2013, 06:27:41 AM
In general I'm using this:
Code: [Select]
export CFLAGS="-Os -pipe -flto"
export CXXFLAGS="-Os -pipe -fno-exceptions -fno-rtti -flto"
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig

./configure --prefix=/usr/local

make

-fuse-linker-plugin is not necessary as toolchain is using it automatically. Also toolchain is using proper CPU settings by default for the RPi, no need for -march and so on.