Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building chrome with libc++ takes 22% (7 minutes) longer than building it with libstdc++ #14959

Closed
nico opened this issue Dec 12, 2012 · 10 comments
Labels
bugzilla Issues migrated from bugzilla libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. performance worksforme Resolved as "works for me"

Comments

@nico
Copy link
Contributor

nico commented Dec 12, 2012

Bugzilla Link 14587
Resolution WORKSFORME
Resolved on Jul 13, 2016 12:12
Version unspecified
OS All
Attachments libstdc++ build log, libc++ build log, python script
CC @ismail,@mclow

Extended Description

I tried building chrome with libc++ (since we need to ship on 10.6, with a libc++ set to "all symbols hidden", and statically linked -- https://codereview.chromium.org/11468030/ see . This is research only for now.)

Doing a full build of the 'chrome' target consistently takes longer with libc++ than with libstdc++ (with clang r168474). Building with libc++ takes around 38 minutes, building with libc++ takes around 31 minutes. (I built several times with both configurations, and the numbers varied by 50s. I interleaved the builds, so it's unlikely that this is explainable by some big background job taking up a huge amount of cpu).

I'm attaching the .ninja_log file for both builds. The format is "start timestamp in ms, end timestamp in ms, 0, output path, hash". With that file, it should be possible to find out for which files the difference is biggest.

@zygoloid
Copy link
Mannequin

zygoloid mannequin commented Dec 13, 2012

Clang -print-stats diff for libjingle_peerconnection.channel.o with libstdc++ and libc++
There doesn't seem to be any one thing causing the difference on the Clang side: there is simply more of everything in the libc++ build. See attachment: nearly 4x as many types, 10x as many implicit special members, 2.5x as many declarations, and so on.

@llvmbot
Copy link
Collaborator

llvmbot commented Oct 3, 2013

@llvmbot
Copy link
Collaborator

llvmbot commented Oct 3, 2013

I had tested compilation time for all combinats of clang, gcc with libcxx and libstdc++ . The compiled code was short:

#include

int main() {
std::cout<<"hello cout\n";
return 0;
}

I repeated every run few times and got consistent results. The results attached.

  • clang is about 50% slower than gcc for all three cases.
  • Windows.h doubles compilation time and not required. Remove it out asap!
  • Even w/o windows.h, libcxx compilation time is twice the libstdc++ compilation time with either compiler.
  • Comparing each compiler with its own library, clang+libcxx compilation is three times as much slower as gcc+libstdc++ !!

@mclow
Copy link
Contributor

mclow commented Aug 19, 2014

  • clang is about 50% slower than gcc for all three cases.
  • Windows.h doubles compilation time and not required. Remove it out asap!
  • Even w/o windows.h, libcxx compilation time is twice the libstdc++
    compilation time with either compiler.
  • Comparing each compiler with its own library, clang+libcxx compilation is
    three times as much slower as gcc+libstdc++ !!

Which gcc/libstdc++ are you comparing against?

@ismail
Copy link
Contributor

ismail commented May 12, 2015

Looks like things haven't improved much:

λ clang -v
clang version 3.7.0 (trunk 236946)
Target: x86_64-suse-linux
Thread model: posix
Found candidate GCC installation: /usr/lib64/gcc/x86_64-suse-linux/4.8
Selected GCC installation: /usr/lib64/gcc/x86_64-suse-linux/4.8
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64

λ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib64/gcc/x86_64-suse-linux/4.8/lto-wrapper
Target: x86_64-suse-linux
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64 --enable-languages=c,c++,objc,fortran,obj-c++,java,ada --enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.8 --enable-ssp --disable-libssp --disable-plugin --with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux' --disable-libgcj --disable-libmudflap --with-slibdir=/lib64 --with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch --enable-version-specific-runtime-libs --enable-linker-build-id --enable-linux-futex --program-suffix=-4.8 --without-system-libunwind --with-arch-32=i586 --with-tune=generic --build=x86_64-suse-linux --host=x86_64-suse-linux
Thread model: posix
gcc version 4.8.3 20141208 [gcc-4_8-branch revision 218481] (SUSE Linux)

λ cat t.cpp
#include

int main() {
std::cout<<"hello cout\n";
return 0;
}

λ time clang++ t.cpp
clang++ -std=c++14 -stdlib=libc++ -fuse-ld=gold t.cpp 0.67s user 0.02s system 99% cpu 0.692 total

λ time g++ t.cpp
g++ t.cpp 0.09s user 0.01s system 96% cpu 0.107 total

@llvmbot
Copy link
Collaborator

llvmbot commented May 12, 2015

It would be unfair to compare g++ w/ libstdc++ and clang w/ libc++. I'll look into comparing the same clang with both libstdc++ and libc++. However this is very low on my priority list.

@ismail
Copy link
Contributor

ismail commented May 12, 2015

It would be unfair to compare g++ w/ libstdc++ and clang w/ libc++. I'll
look into comparing the same clang with both libstdc++ and libc++. However
this is very low on my priority list.

Well thats only a 1x slowdown:

λ time clang++ -std=c++11 -stdlib=libstdc++ t.cpp
clang++ -std=c++14 -stdlib=libc++ -fuse-ld=gold -std=c++11 -stdlib=libstdc++ 0.29s user 0.03s system 99% cpu 0.316 total

λ time clang++ -std=c++11 -stdlib=libc++ t.cpp
clang++ -std=c++14 -stdlib=libc++ -fuse-ld=gold -std=c++11 -stdlib=libc++ 0.60s user 0.03s system 99% cpu 0.633 total

@mclow
Copy link
Contributor

mclow commented Jul 6, 2015

I don't really think that this is a bug. I think that we have been comparing different things.

First, some timings that I just did. (All of these, I ran several times)

$ time totclang -c -std=c++11 -stdlib=libstdc++ bug.cpp

real 0m0.187s
user 0m0.156s
sys 0m0.025s

$ time totclang -c -std=c++11 -I /Sources/LLVM/llvm/projects/libcxx/include bug.cpp

real 0m0.346s
user 0m0.311s
sys 0m0.030s

Seems pretty straightforward, right?

But that's comparing libstdc++ 4.2.1, a C++03 standard library implementation, to ToT libc++ a C++11 library implementation. The C++11 standard library is much larger.

So, let's compare apples to apples. Let's look at more modern libstdc++ versions - ones that implement the full C++11 standard library. (Note that libstdc++ didn't get most of the C++11 stuff until 4.8.x, and didn't really have all of it until 5.1)

$ time totclang -c -std=c++11 -I /Sources/gcc/gcc-4.9.2/bin/include/ bug.cpp

real 0m0.344s
user 0m0.309s
sys 0m0.032s

$ time totclang -c -std=c++11 -I /Sources/gcc/gcc-5.1.0/bin/include/ bug.cpp

real 0m0.345s
user 0m0.304s
sys 0m0.032s

Now the difference is about 1 ms - probably less than the uncertainty in the timing.

I would appreciate it if others would try this, and see if it matches my findings; but I'm tempted to close this as "works for me".

@ismail
Copy link
Contributor

ismail commented Jul 6, 2015

I would appreciate it if others would try this, and see if it matches my
findings; but I'm tempted to close this as "works for me".

Similar results on Linux with ToT clang and gcc 5-branch.

@mclow
Copy link
Contributor

mclow commented Jul 13, 2016

Closing because no one disputed my "works for me" examples in a year.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
@Quuxplusone Quuxplusone added the worksforme Resolved as "works for me" label Jan 20, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. performance worksforme Resolved as "works for me"
Projects
None yet
Development

No branches or pull requests

5 participants