Boost logo

Boost Users :

From: Dominique Pellé (dominique.pelle_at_[hidden])
Date: 2023-04-17 13:32:14


Hi

1) Compiling the attached "brands.cpp" file which uses
boost::container::flat_set is very slow with clang when using
boost-1.81.0. It was much faster with boost-1.80.0 somehow.

2) Furthermore, the size of the .text section is much bigger
when using boost-1.81.0 than with boost-1.80.0 when using clang.

The source file is a simplification of an actual file in my project.
Note that the code is in anonymous namespace (removing the
anonymous namespace makes the compilation time much faster,
presumably because there are more optimizations in the
anonymous namespace).

Benchmarks with clang-16 + boost-1.81.0 (on Linux Ubuntu-22.04):
```
$ time clang++-16 -isystem boost-1.81 -O2 -DNDEBUG \
     -std=c++14 -o brands.o -c brands.cpp

real 1m46.638s
user 1m46.090s
sys 0m0.520s

$ size brands.o
   text data bss dec hex filename
2403932 20032 48 2424012 24fccc brands.o
```

Compare with the older boost-1.80.0:
```
$ time clang++-16 -isystem boost-1.80 -O2 -DNDEBUG \
     -std=c++14 -o brands.o -c brands.cpp

real 0m2.163s
user 0m2.122s
sys 0m0.041s

$ size brands.o
   text data bss dec hex filename
 101280 20032 48 121360 1da10 brands.o
```

In other words:
- file is 81 times slower to compile with boost-1.81 than with boost-1.80
- the .text section is 23 times bigger with boost-1.81 than with boost-1.80

This may be a clang compiler issue, but since the performance
regression is introduced from boost-1.80.0 to boost-1.81.0
I'm, reporting it here (I may report it to clang later depending on
how the discussion here goes).

It's even worse with older clang compilers. The table below shows
the compilation time of brands.cpp file and size of the .text section
for with various compilers using boost-1.80 and boost-1.81:

```
compiler boost compilation time size .text section
-------- ----- ---------------- ------------------
clang-16 1.81 106.638 sec 2,403,932 bytes
clang-16 1.80 2.164 sec 101,280 bytes

clang-15 1.81 137.508 sec 2,861,332 bytes
clang-15 1.80 2.527 sec 107,944 bytes

clang-14 1.81 153.504 sec 3,033,487 bytes
clang-14 1.80 2.294 sec 111,599 bytes

clang-5.0 1.81 276.031 sec 2,720,187 bytes
clang-5.0 1.80 2.328 sec 126,811 bytes

gcc-12.1 1.81 2.821 sec 139,833 bytes
gcc-12.1 1.80 2.505 sec 140,217 bytes

gcc-7.5 1.81 1.943 sec 121,497 bytes
gcc-7.5 1.80 1.707 sec 122,050 bytes
```

Regards
Dominique

PS: full versions of compiler used in above table (--version option):

- Ubuntu clang version 16.0.2
(++20230414073413+b5aa566a7e53-1~exp1~20230414073428.73)
- Ubuntu clang version 15.0.7
- Ubuntu clang version 14.0.0-1ubuntu1
- clang version 5.0.2 (tags/RELEASE_502/final)
- gcc-12 (Ubuntu 12.1.0-2ubuntu1~22.04) 12.1.0
- gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0




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