The title sums up pretty much the entire story, I was reading this and the key point is that
A bigger executable means more cache misses
and since a static executable it's by definition bigger than one that is dynamically linked, I'm curious about what are the practical considerations in this case.
The article in the link discusses the side-effect of inlining small functions in OS the kernel. This has indeed got a noticeable effect on performance, because the same function is called from many different places throughout the a sequence of system calls - for example if you call open
, and then call read
, seek
write
, open
will store a filehandle somewhere in the kernel, and in the call to read
, seek
, and write
, that handle will have to be "found". If that's an inlined function, we now have three copies of that function in the cache, and no benefit at all from read
having called the same function as seek
and write
does. If it's a "non-inline" function, it will indeed be ready in the cache when seek
and write
calls that function.
For a given process, whether the code is linked statically or dynamically, once the application is fully loaded will have very small impact. If there are MANY copies of the application, then other processes may benefit from re-using the same memory for the shared libraries. But the size needed for that process remains the same whether it is shared with 0, 1, 3, or 100 other processes. The benefit in sharing the binary files across many executables come from things like the C library that is behind almost every single executable in the system - so when you have 1000 processes running in the system, that ALL use the same basic runtime system, there is only one copy rather than 1000 copies of the code. But it is unlikely to have much effect on the cache efficiency on any particular application - perhaps common functions like strcpy
and such like are used often enough that there is a small chance that when the OS task switches, it's still in the cache when the next application does strcpy
.
So, in summary: probably doesn't make any difference at all.