public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Holger Hoffstätte" <holger@applied-asynchrony.com>
To: gentoo-user@lists.gentoo.org
Subject: [gentoo-user] Comparatively slow clang startup vs. gcc - reasons?
Date: Tue, 9 Oct 2018 17:55:52 +0000 (UTC)	[thread overview]
Message-ID: <pan$71fd9$26195c19$ea3002bb$f6fea6ee@applied-asynchrony.com> (raw)


(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



             reply	other threads:[~2018-10-09 17:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-09 17:55 Holger Hoffstätte [this message]
2018-10-10  3:29 ` [gentoo-user] Comparatively slow clang startup vs. gcc - reasons? P Levine

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='pan$71fd9$26195c19$ea3002bb$f6fea6ee@applied-asynchrony.com' \
    --to=holger@applied-asynchrony.com \
    --cc=gentoo-user@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox