16
Any programmer knows that when building a C/C++, the compiler can optimize the code to generate faster executables. But, it is also said that there is the compiler optimization for your processor.
This means that if I created a C program and compiled it on a desktop with an Intel Core i3, the program is optimized to run at peak performance on the Intel Core i3 but will normally run on other x86_64 processors. I don’t know if that’s true, just saying.
Based on this, I see a lot to say around that the best way to have a program running at maximum efficiency on your computer is to install it directly from the source code. So much so that some Gentoo Linux enthusiasts make use of this idea to say that Gentoo Linux is the fastest distribution on the planet (Gentoo is a distribution where everything is installed directly from source code, from kernel to most basic applications).
But I’m suspicious of all this. Is this talk that something compiled on your computer will run at peak performance on it real? And, adding: The fact that Gentoo Linux is a distribution where everything is installed directly from the source code actually makes it a system that has a remarkable performance?
Interesting. But the -O3 option is not dangerous because it is dangerous for the compiler to change the behavior of the program?
– Sid
@Sid For programs that are not full of Undefined behaviour and related, no. No optimization changes well-defined code behavior. If you need to switch options for your code to work, there is something wrong with the code and not with the option ;)
– Guilherme Bernal
So I think playing -O3 in the Gentoo file of which I don’t remember the name, a file that configures global flags by compiler is not recommended. Compiling things straight from source I see thousands of warnings of unused variables, deprecated functions, etc. But, and the talk that Gentoo is the fastest distribution that exists because it’s all made from source code, it’s true?
– Sid
@Sid If you’re compiling with
-march=native
the performance gain is about 30%, in general. But remember that to tell you whether it is faster or not you need to attend oranges with oranges. Geento will be faster than any other distribution that uses the same packages in the same versions. When you start comparing bananas with apples none of this makes sense. About optimizing break a library, I would consider this a bug.– Guilherme Bernal
No, I don’t think it would be a bug because it has the premise that the product developers are 100% concerned about the quality of the code, which is not so. If it were, I wouldn’t see thousands of warnings while compiling Mate. Besides, the fact that the library is out there doesn’t mean that it’s good, Openssl says so. Have you seen the code of that freak?
– Sid
Well, then I guess the answer is that specific optimization only for your computer exists, doesn’t it? But not by default, it requires flags.
– Sid
@Sid I consider a bug, but it is likely that they mark as WONTFIX. Ai goes from library to library. Even the guys from glibc claim that it is impossible to make a libc without warnings... About optimization, yes. If you just compile without touching the flags (probably Gentoo does) you get nothing better than a generic binary downloaded from the internet. But you should also turn on some optimization, otherwise there will be no way for the compiler to take advantage of the latest instructions. At least
-ftree-vectorize
.– Guilherme Bernal
Looking at all this, I wonder what is this Gentoo: If static optimization is only available through flags, What is the use of creating a system from which you spend hours and hours compiling your apps to have a full OS and ultimately the result will be the same as a generic binary distribution? - So I don’t even think about trying Gentoo.
– Sid
@Sid Ora, Gentoo uses these flags, if nothing would make sense.
– Guilherme Bernal