Improving program startup with fastbind [HP-UX Linker] White paper

4
It can be seen that most of the startup time is being spent in applying relocations.
The fastbind(1) tool helps avoid this startup overhead. It caches the results of the symbol search, so
that the dynamic loader can use the cached results directly during subsequent runs.
Working of fastbind
The working of fastbind is as follows:
1. fastbind invokes a dry run of the program and sends the appropriate options to the dynamic
loader (to put it in “fastbind mode”).
2. During a regular run, the dynamic loader loads the shared libraries, processes the startup
relocations, and performs symbol searches as required.
3. The dynamic loader communicates the results of the symbol searches to fastbind.
4. fastbind records these symbol search results into the executable.
5. During subsequent runs of this executable, the dynamic loader finds the recorded information
and uses it, saving the time spent in searching symbol tables.
This fastbind data recorded in the executable is fully valid only for those runs of the executable that
use the same shared libraries as in the fastbind run. If any of the libraries change, or if any of the
libraries is replaced by a different one at load time because of different LD_LIBRARY_PATH or
SHLIB_PATH settings, the fastbind data ceases to be fully valid. In such cases, the dynamic loader
attempts to use as much of the fastbind data as possible, to minimize the startup overhead. However,
it is recommended to execute fastbind again to refresh fastbind data in an executable each time any
of its needed libraries change. Further, fastbind is of best use when used on an installed executable in
its runtime environment, rather than only at the time the executable is built.
Caution
During the fastbind run, the dynamic loader follows the same rules for searching needed shared
libraries as during a normal run of the executable. Therefore, in a fastbind run it is necessary to use
the same values for the shell variables LD_LIBRARY_PATH and SHLIB_PATH that are used when
running the executable. This may involve inspecting any wrapper script the application may use to
invoke the executable in question.
Figure 2 shows examples of fastbind invocation. The first invocation is on a system command that
does not need any library search paths set. The second example is on the mozilla application, which
needs LD_LIBRARY_PATH to be set correctly for finding the necessary libraries.