Will performance be better (quicker) if I manually compile the source for a software component for the actual machine that it will be used on, compared to if the source was compiled on another platform perhaps for many different architectures? I got some good results compiling source that I downloaded and I wonder whether this was due to compiling it instead of downloading a pre-compiled binary which is often the case with software updates.

  • 2
    Compiling for compatibility with many architectures potentially eliminates certain optimizations that may be possible when compiling for a single architecture. Commented Oct 4, 2012 at 22:50
  • 1
    Aside from being more targeted (which will almost always be beneficial), you will probably also encounter large differences between compilers - different compilers support different optimisations, and sometimes performance bottlenecks may be optimised away by one, but not the other(s).
    – Daniel B
    Commented Oct 5, 2012 at 7:27

3 Answers 3


In many (if not most) cases, yes. This because the compiler can produce native code optimized for that particular CPU and environment. The code is more "targeted".


Compiling from sources gives you an advantage of setting the compiler flags the way you want for your specific platform. Downloading a package that has been compiled with the same exact settings as yours would offer no difference, but changing the settings from the defaults can get you big improvements.

For example, if the binaries offered for download were compiled for debugging (intentionally or by mistake), turning on more aggressive optimization will improve performance in nearly all situations. On the other hand, if the compiled code is optimized to the max, you would not see any difference.

  • So my compiling effort might not have been in vain. I downloaded the source to mod_jk and compiled and it got very fast and I wonder if that was due to the manual compilation. Thank you for the answer. Commented Oct 5, 2012 at 5:15

This really depends on the two compilers and compiler flags used. Usually, the compiler and flag settings on your local machine are more appropriate to your particular machine if you have things configured correctly.

But, if, for instance, the pre-built binary happened to be built with a much better optimizing compiler (or a benchmark special designed with flags tuned for that particular piece of code and by luck appropriate for your system) compared to the compiler on your system, then it's possible that whatever compiler is on your system might actually produce worse performance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.