Faster startups by fixing C++ object files

Leon Bottou, updated on september 4th, 2001
WARNING --- This information is obsolete. Go here instead.

What is objprelink?

This hack was inspired by a paper by Waldo Bastian. Program objprelink runs after the C++ compiler and before the C++ linker. It transforms the .o files and tries to replace expensive relocations by cheaper ones (details, more details). This eventually requires less work from the dynamical loader and provides for faster startups in large C++ applications.

How much faster?

The dynamic loading time for application konqueror is reduced by 50%. I tried but was unable to obtain better results by enabling lazy linking on the i386. Yet this can be really snappy when the the pages are buffered. Konqueror's start-up time is now caused by disk accesses. This means that the dynamical loading time is no longer the bottleneck.

How to proceed?

The current code has only been tested on a linux-x86 machine. There are step-by-step instructions. But be warned that this is not easy. You should not even try unless you are familiar with compiling QT and KDE from the sources.

Are there other solutions?

Jakub Jelinek's prelinker processes the executable and .so files and pre-computes the relocations. Jakub's work has a greater potential. You need to have a special version of glibc and a special version of binutils. My understanding is that there will be no speed-up unless all the libraries listed by ldd to have been compiled with the patched binutils and processed by the prelinker. That is fine if you are rebuilding your entire linux system from scratch. The objprelink program is more flexible because it gives you a speed-up by simply recompiling some critical libraries or simply installing a new version of these libraries only. Both approaches are perfectly compatible. Objprelinked object should also load faster on systems built using Jakub's patches. But that will not matter much.