c/9655: Slow linking times, even after gcc -fno-merge-constants used.

kslavin@dsl-only.net kslavin@dsl-only.net
Tue Feb 11 07:06:00 GMT 2003


>Number:         9655
>Category:       c
>Synopsis:       Slow linking times, even after gcc -fno-merge-constants used.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Feb 11 07:06:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Keith R. Slavin
>Release:        gcc version 3.2,  GNU ld version 2.13.90.0.2
>Organization:
>Environment:
Red Hat 8.0, AMD 1GHz Athalon, 1GByte RAM.
gcc configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --host=i386-redhat-linux --with-system-zlib --enable-__cxa_atexit
Thread model: posix
gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7)

>Description:
Having already compiled with -fno-merge-constants, I have taken the link time (using GNU ld version 2.13.90.0.2 20020802) from 17 minutes down to over 2 minutes. The same code used to link in under 2 seconds using GNU ld version 2.10.90 (with BFD 2.10.0.18).

Firstly, it seems that -fno-merge-constants should be changed to -fmerge-constants - I have seen elsewhere people reporting a factor of 1000 slowdown due to not using this flag. However, this is not the only factor slowing linking. I am still 100x slower than the old ld. I have no idea why. The link only uses 47MBytes of RAM, and the CPU load averages over 90%.


time gcc -static cache_xxx.o xxx_interface.o xxx_main.o cpu_interface_xxx.o my_getopt.o read_ppm_header.o resizer.o resizer_interface.o /home/kslavin/atools/libraries/asim/wrapper_lib.o /home/kslavin/atools/libraries/asim/asim_lib.o ../../o_intermediates/age_machine.o ../../o_intermediates/asim_models.o ../../o_intermediates/cache_update.o ../../o_intermediates/xxx_cache.o ../../o_intermediates/dram.model.o ../../o_intermediates/get_transfer_mask.o ../../o_intermediates/mask_table.o ../../o_intermediates/system_RAM_xxx.o ../../o_intermediates/top_level.model.o ../../o_intermediates/transfer_machine.o -o xxx2_sim -lm -lpthread -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --host=i386-redhat-linux --with-system-zlib --enable-__cxa_atexit
Thread model: posix
gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7)
/usr/lib/gcc-lib/i386-redhat-linux/3.2/collect2 -m elf_i386 -static -o xxx2_sim /usr/lib/gcc-lib/i386-redhat-linux/3.2/../../../crt1.o /usr/lib/gcc-lib/i386-redhat-linux/3.2/../../../crti.o /usr/lib/gcc-lib/i386-redhat-linux/3.2/crtbeginT.o -L/usr/lib/gcc-lib/i386-redhat-linux/3.2 -L/usr/lib/gcc-lib/i386-redhat-linux/3.2/../../.. cache_xxx.o xxx_interface.o xxx_main.o cpu_interface_xxx.o my_getopt.o read_ppm_header.o resizer.o resizer_interface.o /home/kslavin/atools/libraries/asim/wrapper_lib.o /home/kslavin/atools/libraries/asim/asim_lib.o ../../o_intermediates/age_machine.o ../../o_intermediates/asim_models.o ../../o_intermediates/cache_update.o ../../o_intermediates/xxx_cache.o ../../o_intermediates/dram.model.o ../../o_intermediates/get_transfer_mask.o ../../o_intermediates/mask_table.o ../../o_intermediates/system_RAM_xxx.o ../../o_intermediates/top_level.model.o ../../o_intermediates/transfer_machine.o -lm -lpthread -lgcc -lgcc_eh -lc
-lgcc -lgcc_eh /usr/lib/gcc-lib/i386-redhat-linux/3.2/crtend.o /usr/lib/gcc-lib/i386-redhat-linux/3.2/../../../crtn.o

real    2m26.990s
user    2m17.178s     <--- note: -fno-merge-constants used
sys     0m0.514s


If I temporarily replace ld using the old GNU ld version 2.10.90 (also with the -static flag), I get the following:

time gcc -static cache_xxx.o xxx_interface.o xxx_main.o cpu_interface_xxx.o my_getopt.o read_ppm_header.o resizer.o resizer_interface.o /home/kslavin/atools/libraries/asim/wrapper_lib.o /home/kslavin/atools/libraries/asim/asim_lib.o ../../o_intermediates/age_machine.o ../../o_intermediates/asim_models.o ../../o_intermediates/cache_update.o ../../o_intermediates/xxx_cache.o ../../o_intermediates/dram.model.o ../../o_intermediates/get_transfer_mask.o ../../o_intermediates/mask_table.o ../../o_intermediates/system_RAM_xxx.o ../../o_intermediates/top_level.model.o ../../o_intermediates/transfer_machine.o -o xxx2_sim -lm -lpthread -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --host=i386-redhat-linux --with-system-zlib --enable-__cxa_atexit
Thread model: posix
gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7)
/usr/lib/gcc-lib/i386-redhat-linux/3.2/collect2 -m elf_i386 -static -o xxx2_sim /usr/lib/gcc-lib/i386-redhat-linux/3.2/../../../crt1.o /usr/lib/gcc-lib/i386-redhat-linux/3.2/../../../crti.o /usr/lib/gcc-lib/i386-redhat-linux/3.2/crtbeginT.o -L/usr/lib/gcc-lib/i386-redhat-linux/3.2 -L/usr/lib/gcc-lib/i386-redhat-linux/3.2/../../.. cache_xxx.o xxx_interface.o xxx_main.o cpu_interface_xxx.o my_getopt.o read_ppm_header.o resizer.o resizer_interface.o /home/kslavin/atools/libraries/asim/wrapper_lib.o /home/kslavin/atools/libraries/asim/asim_lib.o ../../o_intermediates/age_machine.o ../../o_intermediates/asim_models.o ../../o_intermediates/cache_update.o ../../o_intermediates/xxx_cache.o ../../o_intermediates/dram.model.o ../../o_intermediates/get_transfer_mask.o ../../o_intermediates/mask_table.o ../../o_intermediates/system_RAM_xxx.o ../../o_intermediates/top_level.model.o ../../o_intermediates/transfer_machine.o -lm -lpthread -lgcc -lgcc_eh -lc
-lgcc -lgcc_eh /usr/lib/gcc-lib/i386-redhat-linux/3.2/crtend.o /usr/lib/gcc-lib/i386-redhat-linux/3.2/../../../crtn.o

real    0m1.868s
user    0m0.949s         <--------------- NOTE!!!!!!!
sys     0m0.527s
>How-To-Repeat:
I have simple programs with huge statically initialized tables (generated from other code), and very little executable code. There is too much stuff (30 MBytes or so) to include here. See above for the linking command line.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name=" "
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=" "



More information about the Gcc-bugs mailing list