As the title says, compared to a normal function, is there a perf hit in calling dll functions? The dll will be loaded by dlopen
.
EDIT:
Ignore dlsym
time because I only do it once per each function.
views:
88answers:
3
A:
Yes there is a performance hit. You do a dlsym call to get the function's address and then call the function with that address. As there is an added dlsym call compared to a function call from the same module, it must be slower. How much that matters? It depends. The only sure way to know is to measure it.
usta
2010-10-11 10:34:27
You are right. But in my case, I only do `dlsym` once for the lifetime of the program for each function. And, additionally I use function pointers to invoke the function. What about then?
nakiya
2010-10-11 10:37:15
@nakiya In that case you only lose the opportunities of optimization you'd otherwise have if the called function was linked statically, i.e. inlining, inter-procedural optimization, constant propagation and the like. In other words it's really no different from calling a function of the same module through a function pointer.
usta
2010-10-11 11:55:32
+5
A:
Calls to DLL functions are indirect by address and the compiler can't inline them, so there is a slight performance hit.
You should only worry if you use them in a performance critical inner loop and after profiling them.
Axel Gneiting
2010-10-11 10:57:59