Explicit template instantiation and debug load time

62 Views Asked by At

I have been wondering if the use of explicit template instantiation can help reduce the time that it takes the debugger to load binaries. Something similar to reducing link time by the same mechanisms.

In the same vein, are there any ways to measure this? I can use readelf -e to see the size of the debuginfo, like

 [33] .debug_info       PROGBITS         0000000000000000  048d175c
       000000000583f7f3  0000000000000000           0     0     1   

Is there anything finer grained (without having all of the gory details)?

For info, this is with GCC and GDB on Linux (RHEL 6.6).

1

There are 1 best solutions below

0
On

Something similar to reducing link time by the same mechanisms.

It most likely will not work.

The mechanism used to speed up the build via explicit instantiation: instead of emitting automatic template method(s) into every .o which needs them, and then having the linker discard duplicates, it explicitly instantiate the method(s) into a single file (resulting in smaller .o files and less work for the linker).

But for debug info, the debugger is not looking at the .o files; it looks at the resulting linked executable or shared library. And by the time the link is done, the linker has already discarded all (or most) of the duplicates.

So you will probably not observe any speedup from explicit instantiation.

(It may not be possible to discard all duplicate debug info, so you may in fact find a tiny speedup, but I doubt it will be anywhere near 40% improvement.)