clang vs gcc build performance (executable not build time)
Luboš Luňák
l.lunak at collabora.com
Tue Nov 23 16:11:59 UTC 2021
On Tuesday 23 of November 2021, Michael Meeks wrote:
> On 22/11/2021 16:28, Arnaud Versini wrote:
> > There is no
> > significant difference between both clang builds (changing lib C++ from
> > libstdc++ to libc++) but gcc is slower than clang. Of course all builds
> > don't use system libraries in this case to compare between lib C++, and
> > builds are optimised and use LTO.
>
> Looks interesting.
>
> Lubos - what are our build defaults currently and do you have thoughts
> on changing them ? it would be great to poke at Arnaud's blog / work
> as/when it gets published =)
That decision is not really up to me. AFAIK projects like Firefox or Chromium
build exclusively using Clang. I wouldn't mind using Clang for everything,
but I don't know how others would see that.
> > OpenSUSE 7.2 Clang + libc++ Clang + std Gcc + std
> > Run 1 50,923045275 45,456441587 45,878275287 49,487550577
Do you have more tests than this one? With the data you've provided that's
good enough as an indicator that it should be investigated, but not much
more, as there can be various factors that cause such results. Maybe Clang
just happened to optimize better one function that's called often in this
case, maybe one of the compilers is older than the older, maybe whatever
else.
Can you try more different tests?
> > I also noticed that libengine12 is really bigger with GCC but I've not
> > have that data on me now.
>
> That's interesting too - how much bigger? I would assume that we use
> -Os to optimize for size as well as for speed: since huge binaries may
> be more optimal in theory but can be much slower to load and kill your
> cache in practice: but it sounds like this is some combination of bigger
> & slower.
We don't use -Os, at least my local optimized build doesn't. A bunch of
solenv/gbuild/platform files do set it, but it doesn't get selected here. And
if it's because my build uses Clang and those -Os get used only with GCC and
not Clang, then incidentally that would solve the whole mystery. Checking
what flags get used for both builds is certainly something that should be
done. Arnaud?
And according to logs those -Os come from at least 10 years ago, so if the
idea is to use them, maybe it would be a good idea to re-check the effect
they have. I'm personally sceptical that -Os would help on the desktop.
> I wonder what the compile option difference is.
Theoretically there shouldn't be any difference related to performance. There
are differences in handling PCHs, some debuginfo options may be different and
stuff like that, but AFAIK performance flags should be the same. Although, as
said above, maybe that's not the case.
> > I hope this could be an idea of improvement ! Next crazy test I would
> > like to do is between MSVC and clang on windows ! But it seems harder !
Stephan Bergmann does clang-cl builds on Windows, so it should work, although
I don't remember how difficult it is to set up.
--
Luboš Luňák
l.lunak at collabora.com
More information about the LibreOffice
mailing list