DLL function call overhead

How big is the performance score when calling functions from a DLL? DLL loading is not a problem for us, the number of calls in our highperf library will not be large.

Approximately how many commands / clock cycles a single call to a static library call makes?

+6
source share
1 answer

My answer is based on how the dynamic linker Linux / glibc / ELF works, but I would suggest that the general answer is the same for other platforms:

There is a difference between the first call of a dynamically loaded character and the next call. The first road challenge may involve many cycles. All other calls are more or less than 1 - 2 instructions.

The principle of operation is that the linker has set up an entry in the procedure binding table, which grabs the address for this external function from the global offset table. First, call the address of the GOT point on the stub that starts the dynamic linker to resolve the real address of the function in the DLL. This can take many cycles, but once this is done once, the dynamic linker will direct the GOT entry directly to the function, so the next time the PLT code is called, it is called directly to the function.

Here is a link to a pretty good walk on this process: http://www.technovelty.org/linux/pltgot.html

+11
source

Source: https://habr.com/ru/post/896550/


All Articles