I have a question about reducing the dynamic linking time.
I've got a binary which links with 189 shared libraries. I profiled the execution with perf
tool and the dynamic linker (ld.so) takes up 40% of the runtime of my program, approximately 90 milliseconds of time.
Is there any way to optimize dynamic library loading time, or am I forced to use static linking?
I run this program a lot of times.
-fvisibility=hidden
(and selectively using __attribute__((visibility("default")))
for symbols that you do want to export)--as-needed
to minimize library dependenciesLD_BIND_NOW
is not set and library is not compiled with -Wl,-z,now
)/DELAYLOAD
) and macOS (-lazy-l
) and on Linux you can use Implib.so.Library load time can be measured by exporting LD_DEBUG=statistics