While that may be true, I don’t think it is a desirable trend: For the most part, optimization is already “good enough”, and additional optimizations have the unfortunate trend to trade large compile-time increases for very minor (and/or very rare) improvements to run-time performance.
I just kind of think the author is misguided here. If llvm is looking to be competitive as a backend for production C and C++, there's just really no such thing as "good enough". A lot of the use cases of C and C++ always want better performance. For good enough performance, there's just about every other language and framework. If you've tied your wagon to something so intertwined with the C++ ecosystem, you should go into it with this knowledge.
The other issue is that I didn't see discussion of debug build times. I could have missed it though. At any rate, if debug build times aren't getting worse, then this more or less shows that there's no collateral costs to adding optimizations. It's building slower because more time is spent optimizing and no other reason. At that point, what's needed is not really better build times at max optimization, but just more and easier to use options (e.g. -O1.5) to disable less efficient optimizations.
I just kind of think the author is misguided here. If llvm is looking to be competitive as a backend for production C and C++, there's just really no such thing as "good enough". A lot of the use cases of C and C++ always want better performance. For good enough performance, there's just about every other language and framework. If you've tied your wagon to something so intertwined with the C++ ecosystem, you should go into it with this knowledge.
This might be a bit controversial, but as a high-performance computing researcher and compiler constructor myself, I agree with the author for the most part. If you need absolute maximum performance, you either shouldn't expect your compiler to give it to you or you shouldn't be writing in C/C++.
Here's what good enough means: the compiler's output won't bottleneck your optimization efforts. And this is mostly true. No matter what sort of application you're writing, the quality of LLVM's output is so high that the most important optimizations come from large-scale reorganizations of computation and resource loading, full stop.
Discovering these reorganizations in a setting as unconstrained as C/C++ just isn't possible. The set of legal optimization steps depends on the particulars of the program that a general-purpose compiler isn't able to reason about. Even if it could, the space is so large that there's no way to explore it. Even if it could do that, the fastest program might not even be reachable from a series of legal steps. Eventually you'll need to assume your compiler can solve the halting problem.
So the alternatives are to either painstakingly write assembly, or encode the particulars of the problem you're trying to solve in a domain-specific language. In a well-designed DSL, the space of allowable optimizations is much more targeted and you can push your performance much farther than you can in C/C++ alone.
64
u/quicknir May 11 '20
I have two issues with the article.
I just kind of think the author is misguided here. If llvm is looking to be competitive as a backend for production C and C++, there's just really no such thing as "good enough". A lot of the use cases of C and C++ always want better performance. For good enough performance, there's just about every other language and framework. If you've tied your wagon to something so intertwined with the C++ ecosystem, you should go into it with this knowledge.
The other issue is that I didn't see discussion of debug build times. I could have missed it though. At any rate, if debug build times aren't getting worse, then this more or less shows that there's no collateral costs to adding optimizations. It's building slower because more time is spent optimizing and no other reason. At that point, what's needed is not really better build times at max optimization, but just more and easier to use options (e.g. -O1.5) to disable less efficient optimizations.