igraph is written in C89 (not C++), which does not have explicit support for inline functions. Usually, the compiler would automatically inline functions where possible, but it can not do this across compilation units—unless we use link-time optimization.
igraph does have several functions which perform such a small task that the time they take may be comparable to the overhead from the function call. For example, the random number generation functions can only return a single random number at a time.
In a preliminary test, I saw a speedup from 9.1 s to 5.1 s just by compiling with
-flto=thin on macOS. We should investigate if providing official binaries compiled with LTO is useful, e.g. for the Python interface. On macOS I already do this for the Mathematica interface.
Ideally, we should also try to eliminate this issue with very small functions that cannot be inlined, and make sure that such functions are not called in a loop when avoidable.
For example, in C++ it is safe (performance-wise) to do
for (int i=0; i < vec.size(); ++i) and call
.size() in each iteration, because it gets inlined anyway. Doing the same with
igraph_vector_size() would slow things down. But calling
vecor_size repeatedly is avoidably, while calling the RNG repeatedly is not.