RFC: Split <functional> into smaller pieces

Jonathan Wakely jwakely@redhat.com
Thu Oct 13 19:29:00 GMT 2016


On 13/10/16 19:19 +0100, Jonathan Wakely wrote:
>On 13/10/16 18:34 +0100, Jonathan Wakely wrote:
>>Code which doesn't need the whole of <functional> should include the
>>relevant <bits/*> header instead.
>>
>>This means that we don't need to pull the whole of <functional> (and
>><vector> and <unordered_map>) into <memory> just because shared_ptr
>>wants to use reference_wrapper in one place.  This reduces <memory>
>>from 48kloc to 30kloc!
>
>With a few additional changes to remove <functional> from other
>headers we can get:
>
>old  |  new  | Header
>------|-------|-------
>47571 | 30449 | memory
>49620 | 32498 | thread
>49049 | 30861 | condition_variable
>49459 | 31271 | shared_mutex
>54215 | 37745 | future      75063 | 68509 | regex
>
>Apart from <regex>, which is enormous even without <functional>, these
>are pretty dramatic improvements.

And to show it's not just line-count that changes, here are the
-ftime-report numbers for including each header in an otherwise empty
file, compiled with -O0:

memory:
 TOTAL  :   0.66      0.19        0.86        56342 kB
 TOTAL  :   0.41      0.09        0.49        40487 kB

thread:
 TOTAL  :   0.73      0.15        0.90        63030 kB
 TOTAL  :   0.59      0.11        0.71        47508 kB

condition_variable:
 TOTAL  :   0.77      0.15        0.93        63641 kB
 TOTAL  :   0.50      0.11        0.61        47360 kB

shared_mutex:
 TOTAL  :   0.79      0.14        0.94        63985 kB
 TOTAL  :   0.50      0.10        0.61        47705 kB

future:
 TOTAL  :   1.18      0.20        1.40        92564 kB
 TOTAL  :   0.90      0.17        1.09        78584 kB

regex:
 TOTAL  :   1.14      0.24        1.39        100089 kB
 TOTAL  :   1.04      0.24        1.30        91322 kB



More information about the Libstdc++ mailing list