[Bug libstdc++/107675] New: [13 Regression] GCC-13 is significantly slower to startup on C++ programs

tnfchris at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Nov 14 13:03:28 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107675

            Bug ID: 107675
           Summary: [13 Regression] GCC-13 is significantly slower to
                    startup on C++ programs
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tnfchris at gcc dot gnu.org
  Target Milestone: ---
            Target: aarch64*

The following simple testcase:

#include <cstdio>

int main(int argc, char** argv) {
    printf("Hello world\n");
    return 0;
}

is on average twice as slow as GCC 12 during startup:

> perf diff perf.data.gcc.12 perf.data.gcc.13

# Event 'cycles'
#
# Baseline  Delta Abs  Shared Object     Symbol
# ........  .........  ................  ...............................
#
   100.00%    +42.66%  gcc-13.exe        [.] fde_single_encoding_compare

Looking at perf the entirety of of the difference is spent in __libc_start_main
which on GCC 13 calls __libc_csu_init which calls init_object.constprop.0.

This constprop function spends half the time in frame_heapsort and the other
half in fde_single_encoding_compare.  Together these two calls are responsible
for the 2x slower startup.

Is it possible to mitigate this? At startup it's currently executing more than
6.5x the number of instructions as GCC-12 which is quite noticeable on small
devices.


More information about the Gcc-bugs mailing list