Gentoo Archives: gentoo-user

From: "Holger Hoffstätte" <holger@××××××××××××××××××.com>
To: gentoo-user@l.g.o
Subject: [gentoo-user] Comparatively slow clang startup vs. gcc - reasons?
Date: Tue, 09 Oct 2018 17:58:25
Message-Id: pan$71fd9$26195c19$ea3002bb$f6fea6ee@applied-asynchrony.com
(paging Michał Górny..)

I've noticed that clang has gotten really slow, and while it does
great analysis during the various compilation stages (which is fine),
the startup itself is a major contributor to perceived slowness.

Nothing demonstrates this better than running ./configure in a random
project - here nghttp2:

$time ./configure
./configure  5.83s user 1.10s system 100% cpu 6.866 total
./configure  5.73s user 1.04s system 101% cpu 6.669 total
./configure  5.74s user 1.04s system 101% cpu 6.671 total

$time ./configure CC=clang CXX=clang++
./configure CC=clang CXX=clang++  21.43s user 2.56s system 99% cpu 24.011 total
./configure CC=clang CXX=clang++  21.37s user 2.61s system 100% cpu 23.911 total
./configure CC=clang CXX=clang++  21.56s user 2.51s system 100% cpu 23.995 total

That's almost 3 times slower doing not much at all.

A major contributor to this is the relatively large number of shared
objects being loaded as a consequence of building llvm with shared objects,
incurring large relocation costs compared to short-lived runs.
gcc on the other hand consists of mostly-monolithic binaries, minus the
few usual suspects like zlib etc.

A brief run with "perf record" compiling helloworld.c and comparing
the "perf report" output between gcc and clang confirms that clang
spends the vast majority of its time in ld.so.

Can we do something about this? I remember that llvm had optional static
libs, which apparently were removed completely. Is there something
that can be done with linker tricks (better relocation info?) when
building llvm/clang to speed up the .so loading?

curious,
Holger

Replies

Subject Author
Re: [gentoo-user] Comparatively slow clang startup vs. gcc - reasons? P Levine <plevine457@×××××.com>