Re: [PATCH] x86: Turn off GCC branch probability heuristics

Ingo Molnar
2015-04-12T08:07:17Z

* Thomas Gleixner <tglx@linutronix.de> wrote:

> > How much of that 5% comes from code alignment? Or was this on
> > *top* of the 1-byte alignment testt?
>
> I thinks its just the no-guess one:
>
> text data dec patch reduction
>
> 7563475 1781048 10302987
>
> 7192973 1780024 9931461 no-guess -4.8%
>
> 7354819 1781048 958464 align-1 -2.7%
>
> 7192973 1780024 9931461 no-guess + align-1 -4.8%
>
> So with the no-guess applied the align-1 does not matter anymore.

What kernel config and GCC version did you use?

I used x86-64 defconfig+kvmconfig with GCC 4.9.1, and it gave me:

text filename reduction
12566383 vmlinux.expect=10 [==vanilla]
11923529 vmlinux.-fno-guess-branch-probability -5.4%
11903663 vmlinux.align=1 -5.6%
11646102 vmlinux.align=1+fno-guess-branch-probability -7.9%

So there's still appears to be an additional -2.5% to be gained from
turning off GCC branch heuristics.

x86 defconfig was derived from a distro kernel config and is still
pretty close to what distros typically enable, so it's a good
'typical' config to use for testing.

To double check that assumption I also tested a distro kernel .config
and looked at vmlinux sizes:

text filename reduction
12612201 vmlinux.expect=10 [==vanilla]
12107614 vmlinux.-fno-guess-branch-probability -4.1%
12021817 vmlinux.align=1 -4.9%
11846771 vmlinux.align=1+fno-guess-branch-probability -6.5%

this was cloned from a different major Linux distro than the one the
original x86 defconfig was derived from - still the vmlinux sizes are
pretty similar.

So x86 'make defconfig' measurements are pretty representative if you
are looking for a quick, independent way to measure 'typical Linux
distro' kernel characteristics.

( The only bigger difference is that FUNCTION_TRACER was turned on in
the distro config - which bloats function prologues a bit and thus
reduces the relative savings a bit. )

Thanks,

Ingo