4 ms·
Also compilers nowadays are smarter and can perform link time optimizations. Meaning that if of a library you only use a single function, in the final executabl
by alerighi 5y ago
Also compilers nowadays are smarter and can perform link time optimizations. Meaning that if of a library you only use a single function, in the final executable you would only get that single function. In reality code that use static linking could be more efficient than code that uses dynamic linking.
And you have to consider some performance penalty when using shared libraries. First you have a time penalty when loading the executable, since first you have to run the interpreter (ld-linux) and then your actual code. But also for each function call you have to make an indirect jump into it.
- bonzini 5y ago> But also for each function call you have to make an indirect jump into it. Only the first call has a penalty. Then you call into the PLT and the PLT contains a direct jump to the function.
- kaba0 5y agoIt still has a cost over potential inlining (that allows for more optimizations as well). Of course if it is not a hotspot, it is meaningless.
- creamytaco 5y agoThe call into the PLT is a penalty.
- bonzini 5y agoSure but it's not an indirect jump.