Performance difference between compiled and binary linux distributions/packages

gentoopackagesperformance

I was searching a lot on the internet and couldn't find an exact answer.

There are distros like Gentoo (or FreeBSD) which does not come with binaries but only with source code for packages (ports).

The majority of distros uses binary backages (debian, etc.).

First question:
How much speed increase can I expect from compiled package? How much speed increase can I get from real world packages like apache or mysql? i.e. queries per second?

Second question:
Does binary package means it does not use any CPU instructions that was introduced after first AMD 64bit CPU? With the 32bit packages does it mean that the package will run on 386 and basically does not use most of the modern CPU instructions?

Additional info:

  • I am not talking about desktop, but server environment.
  • I dont care about compile time
  • I have more servers, so speed increase more than 15% is worth for using source code packages
  • Please no flamewars.

Best Answer

The performance difference will be in almost all cases minimal and not worthwhile. Good reasons to use source distributions (while rolling your own binary packages, as gentoo's bindist system allows) include:

  • Deploying your own custom patches
  • Customizing your kernel easily
  • Packaging your own updates

If you're not doing any of these things, you don't need a source distribution. For personal use they're very convenient because they allow you to upgrade things incrementally at will without worrying too much about binary compatibility, which is not a concern I see often in an enterprise setting.

It's worth noting that you can do these things with a binary distribution as well, by making your own RPM packages or whatever. The management overhead is similar.

You will basically not see a 15% speed increase by compiling from source. I'd be loathe to estimate it at even as high as 5% in any reasonable case. Compiling from source gets you a couple things:

  • You get to use your preferred compiler version
  • You can direct the compiler to generate instructions from ISA extensions not used in binary distributions' packages, such as AESNI and AVX

However, the compiler very rarely actually generates these anyway, and the overall savings from using them are generally very miniscule when the application's performance is taken as a whole. Things like RAM accesses (and latency) and disk and device latency are much bigger factors, and you should really start there.

Applications which might benefit from a custom compilation that will only run on a relatively recent Intel core i7 or i5 include ones that do a lot of vector math and ones which do a lot of AES encryption and decryption, or require a lot of random numbers. If you want to use the Intel DRBG you would need to do this as well, currently.

If none of these apply to you, you'll be quite happy with any of the debian or red hat based distributions out there, and will have a lot less maintenance overhead.