Boost logo

Boost Users :

Subject: [Boost-users] g++ compilation is slow with Boost's constructs
From: Ilya Murav'jov (muravev_at_[hidden])
Date: 2010-09-06 18:23:07


Hello,

 I've been using several Boost libraries since 1.33 and now I have a
situation that it takes over 4 seconds to compile for some files <= 40Kb
(not so big!), with gcc. I've upgraded my machine recently (AMD X3 425,
2700MHz, 2GB memory) and hoped that things would change but it is still
somewhat a blocker to developing.

 So I began to investigate and found out each invocation of known Boost
constructs has its non-zero cost. I chose a source file(*), commented
out all and then incrementally uncommented functions from beginning,
compiled and measured times. Here is my results (compile time, not run
time!):
- BOOST_FOREACH costs 0.1 sec
- boost::function<> invocation costs 0.05 sec
- boost::lambda::bind() with placeholders costs 0.1 sec
- Boost.Range adaptor transformed() costs ~0.1 too
 As you can see, 10 boost::lambda::bind() slow down your compilation for
 whole 1 second!

 All that is measured against gcc 4.4, Ubuntu 9.10, with the most light
options I picked up: "g++ -g -O0 -pipe" (I need -g for debugging
anyway). Also I found out that gcc 4.2 is the quickest from 4.1, 4.2,
4.3, 4.4 version of gcc, and gcc 4.4 is the most slow one of them (~28%
slower than gcc 4.2). :(

 Therefore, I have a few questions.
1) Are there more means/tricks for faster compilation with g++ I miss?
(what a quickest gcc version?)
2) What compiler is known to be much more speedy for now, if any (icc,
clang, msvc)?
3) Did someone try to investigate (and maybe fix) that gcc bottleneck(s)?

Regards,
 Ilya Murav'jov

(*) I did measures on a source file select.cpp from my project, Bombono
DVD
(http://gitorious.org/bombono-dvd/bombono-dvd/blobs/master/src/mgui/editor/select.cpp)


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net