4 ms·
Ok, security-critical stuff as shared libraries (libjpeg, libz, libssl, etc). Why do we package the other stuff as shared libraries too? GMP, GtK, Qt, OpenCV,
by qznc 10y ago
Ok, security-critical stuff as shared libraries (libjpeg, libz, libssl, etc).
Why do we package the other stuff as shared libraries too? GMP, GtK, Qt, OpenCV, SDL, BLAS, ...
- hollerith 10y agoThe original motive for adding shared libraries to Unix was so that X11 would fit in memory on the machines in use at the time (according to a comment I read many years ago). If the use of shared libraries saves on memory, it probably also saves on L3 and L2 cache, so on the aggressively cached CPU architectures of today, replacing a shared library with a statically-linked version might slow things down by decreasing cache hit rates. In particular, if every KDE application is statically linked to Qt, then when KDE application A's time slice ends, whatever parts of A's copy of Qt are in cache will be invalidated with the result that if B wants one of those parts it will have to fetch it from it's own copy of Qt in memory whereas if A and B shared a copy of Qt, the fetch from memory could be avoided.
- qznc 10y agoHas anybody actually measured it in the last decades?
- hollerith 10y agoI don't know. But we know that Intel and AMD design their CPUs to go as fast as possible on the operating systems people actually use (Windows, Macos, Linux) all of which use dynamic linking. Plan 9 is the only OS I know of that does not support dynamic linking (and Plan 9 simply does not have large libraries -- they have what they call services instead, which are similar to souped-up Unix daemons). Linux and Windows in turn are designed to run as fast as possible on Intel and AMD hardware. After a few iterations of this sort of mutual evolution, it starts to become very unlikely that a change as big as switching a bunch of big libraries from being dynamically linked to being statically linked would actually improve performance because lots of optimizations have been made to squeeze a few percentage points of performance out of the existing system (which includes the practice of shipping most large libraries as shared libraries), and typically those optimizations stop working if there are large changes in the system.
- majewsky 10y agoYou are implying that, for any given shared library, you can classify it as "clearly security-critical" or "clearly not security-critical".