johnbakers
johnbakers

Reputation: 24771

Building all of Boost in a few minutes

Can anyone explain why following these instructions:

http://www.boost.org/doc/libs/1_59_0/more/getting_started/unix-variants.html#easy-build-and-install

... it takes my decent machine 5 hours to build all of Boost, while some folks report doing the same in only 3 minutes ?

Is there another way to build Boost than the one mentioned above that indeed goes pretty quickly (compared to several hours, at any rate).

I am using the Clang compiler on Darwin (Mac) option. Not sure how relevant it is but I have 16 GB RAM and a recent SSD. The clock is 2.3 Ghz.

Edit: I'm happy to report, based on the comments and answers, that using the ./b2 -j4 -d0 options, I got my compilation time down to 13 minutes. Also the -jN option is not listed in the set of available options with the default --help, you must instead call --help-options to see these additional more "advanced" techniques.

Upvotes: 22

Views: 24707

Answers (3)

zaphoyd
zaphoyd

Reputation: 2760

I just ran a few tests with a few different build configs.

Hardware: 2012 MacBook Pro (2.3Ghz Ivy Bridge i7 [i7-3615QM]), factory SSD and 16GB of ram.

Software: Mac OS X 10.11.1 with Xcode 7 (Apple LLVM version 7.0.0 clang-700.1.76). Fresh copy of Boost 1.59.0 from the website.

I tested the following build commands:

Default Build:

./bootstrap.sh && ./b2 -j N

Build forcing the linking of libc++

./bootstrap.sh && ./b2 toolset=clang cxxflags="-stdlib=libc++" linkflags="-stdlib=libc++" -j N

For each I tried three different values for N: 1 (single thread), 4 (matching physical cores), and 8 (matching hyperthreaded cores).

Default linking:

  • With 8 the build time was 6:45 minutes
  • With 4 the build time was 7:22 minutes
  • With 1 the build time was 22:58 minutes

Linking libc++:

  • With 8 the build time was 4:35 minutes
  • With 4 the build time was 5:45 minutes
  • With 1 the build time was 17:15 minutes

Conclusion: Boost shouldn't have to take all day to build on a multi-core system with an SSD even if it isn't brand new. Building with the default (singled thread) does take way longer than a parallel build. The Boost build with clang on OS X does benefit slightly from hyperthreading. Linking with libc++ seems a bit faster as well.

Upvotes: 32

ISanych
ISanych

Reputation: 22690

I guess you are not using parallel build option -jN (where N number of processes, could be little higher than number of cores on your machine). Also 3 min sound like single configuration on machine with sdd or ram disk, and 5 hours like all configuration with single process and slow HDD.

Upvotes: 8

bobah
bobah

Reputation: 18864

Most boost packages are header-only. If you only need those then the installation is just copying files. Based on how many compiled packages you are doing the time may differ by several orders of magnitude. Plus yes, parallel compilation, different machine (Raspberry Pi vs 32 CPU IvyBridge Blade), etc. Plus building from and into /dev/shm can get you significant speedup.

Upvotes: 0

Related Questions