First,if you have more than one Gentoo machine,try DistCC.

But since I only got one,we gonna ignore DistCC for now.

ccache is a great tool which will speed up compilation process,first emerge it.

emerge --ask ccache  

And enable it with your make.conf

vim /etc/portage/make.conf

Add this line to it.

FEATURES="ccache"

Next tool is prelink.prelink will pre-link application’s dynamic library,eventually cut their start-up time.

Emerge it as well.

emerge --ask prelink

And update your environment.

env-update

Then your system should be ready to go.

But we need do little job for old pre-compiled application in /opt,since they can’t be prelinked,we need tell prelink not to attempt to prelink them.

vim /etc/env.d/60prelink

Put this line into it.

PRELINK_PATH_MASK="/opt"

And prelink your system.

prelink -amR

Make sure you have some space left on drive,otherwise,this may fail.

Now let’s focus on CFLAGS and other flags in make.conf,first we need find proper -march and -mtune.

As I mentioned in this blog ,use following command to obtain them.

gcc -v -E -x c -march=native -mtune=native - < /dev/null 2>&1 | grep cc1 | perl -pe 's/ -mno-\S+//g; s/^.* - //g;'

This should produce a line of CFLAGS.But we only need -march and -mtune,add/modify them in make.conf.

CFLAGS="-march=haswell -mtune=haswell -O2 -pipe"

Don’t worry about -msse flags and other feature flags,they will apply to CFLAGS automatically as long as the system is using the correct -march .

Okay,now your system is fully optimized!


Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.