4 ms·
Hi, I just created an account to give you a bit of feedback. When g++4.9 went out, our old mathematical/financial library was finally able to be built with LTO
by melkiaur 9y ago
Hi, I just created an account to give you a bit of feedback.
When g++4.9 went out, our old mathematical/financial library was finally able to be built with LTO.
See, to be effective, devirtualisation requires LTO, it also requires profile-guided analysis to detect the right use-cases to devirtualise, and it requires that your functions can in effect be "hidden" from the outside, so that the compiler can tune the inlined functions.
As our codebase was also portable to Windows (and so, had all the right declspec (dllexport) lying around), we were able to use the -fvisibility=hidden flag. We just had to make sure that everything was within one big fat shared-lib.
On old CPUs (e.g: Nehalem class), our code ran 2 times faster than the same code compiled with -O3. On Haswell-E, it ran 50% faster.
There's also a very cheap way to force devirtualisation: use the C++11 "final" keyword on your methods. G++ can optimise and inline where applicable.
- pawadu 9y agoThank you! I was hoping this could automatically improve performance for existing projects but it seems it is a bit more complicated than that. Either way, 50-100% improvements sounds very nice.