DragonFly kernel List (threaded) for 2003-11
Re: Dynamic linking
:Those who follow freebsd-current know that there has been an epic thread
:about the slowness of dynamic linking in FreeBSD, in which John Dyson and
:Matt Dillon sent some posts. I have been told by an OpenBSD developer that
:they have introduced a cache of the position of the dynamic libraries, and
:that this modification alone was sufficient to improve considerably
:the startup time of KDE. In fact the developer sais that KDE starts up 3
:times faster, but this was perhaps exagerate. Perhaps this a valuable track
:to investigate, since it is apparently a small impact modification of the
Yes. Well, basically the only way to make a dynamic binary 'load'
as fast as a static binary is pre-link the dynamic libraries and the
main binary, write out cache files representing the prelinked result,
and then mmap() the prelinked cache file instead of the DLL. One still
has to check at least timestamps to be sure that none of the DLLs or the
main binary has changed, but otherwise it would very close to a static
Another way to think of it: run the program as per normal but 'save'
an image of it just after the last DLL has been loaded, before the
program's main() function is called.
In fact, it occurs to me that we could use Kip's checkpointing code to
perform this function in a manner similar to the way 'ldd' works. We
could even augment the code to 'copy' the contents of shared segments
in addition to anonymous memory so only a single file need be mmap().
I'm not sure that it is worth persuing because startup times for large
programs are not really a performance bottleneck. Still, if one can
actually achieve a 3x performance improvement loading something like
KDE it might well be worth doing.