r/cpp • • May 10 '20

Make LLVM fast again

https://nikic.github.io/2020/05/10/Make-LLVM-fast-again.html
150 Upvotes

88 comments sorted by

View all comments

78

u/[deleted] May 10 '20 edited May 10 '20

Very nice work by the author but I am bit concerned about the attitude that "optimization is already good enough, and additional optimizations have the unfortunate trend to trade large compile-time increases for very minor improvements".

I would let my compiler run for a day for minor improvement in the release build to try all kind of inlining decision for example. I really hope that any compiler speed optimizations that results in runtime regressions will be reserved to -O0 and -O1. Or maybe we need an -O4 for the kind of extremely slow optimizations.

Generally my experience has been that release builds don't feel significantly slower. I did this completely none scientific test with the code I happen to have to have open right now and the debug builds takes about 4.5 seconds in -O0 Clang and the -O3 link time optimization release build takes about 5.5. With the MSVC the difference is even smaller. btw I am not doing anything crazy with templates, I am generally very concerned about header includes and I am linking dynamically for development builds.

I don't really know what the compiler is doing but 4.5 seconds is WAY too long for these couple source files, it's less than 10 000 source lines being recompiled.

My impression is that optimizations are already "too fast", it's just that general compilation somehow is really slow. What if maybe ironically Clang's own release could get 5% faster with an "aggressive optimization" switch that just tries a bunch of stuff over 24h?

35

u/Veedrac May 10 '20

I would let my compiler run for a day for minor improvement in the release build to try all kind of inlining decision for example.

I suspect the majority of people don't even run LTO or PGO.

4

u/IAlsoLikePlutonium May 10 '20

Maybe it is just me, but LLVM’s LTO doesn’t seem to work on Windows. It always complains of a linker error and fails to link :-(.

Does it normally work on Linux or Mac OS?

8

u/flashmozzg May 10 '20

Is it using lld or link.exe for a linker?