Preload
From openSUSE
Preload is a program that can help speeding up the startup of either individual programs (like e.g. OpenOffice) or whole subsystems (e.g. a graphical session). The following is a description taken more or less literally from a mail and targeted at those who want to know how it works. Usage of it is mostly automatic due to cron jobs and init scripts.
The whole process goes like this: user straces a "session" that interests him, where session might for instance be the complete process tree starting from a rc-script, or simply the startup of e.g. firefox. That strace is fed into "prepare_preload -s -p" (input is strace, output is command file). This parses the strace into simple commands, like
open /usr/bin/firefox stat /etc/ld.so.preload open /etc/ld.so.cache ...
For the distribution a pregenerated set of these files is placed into /etc/preload.d/ . These are somewhat hand-edited to not contain too many machine- or installation-specific paths (some installation specific ones are left in, usually tailored to the default installations).
That's how far the strace involvement goes, it's only used to initially generate the above command files, i.e. simply a list of files that are stated or read by processes.
The rest involves BMAP. Periodically whenever something interesting happened (e.g. new packages installed) update_preload runs "prepare_preload -c" (input is command file) on those command files. This will gather the on-disk layout of all referenced files and directories via the /sbin/print-bmap tool (as far as the filesystem in use allows), and prepare_preload then tries to sort all these accesses into increasing block order (even interleaving accesses to the same file), resulting in a file like:
S /usr/lib/libvorbis.so.0 W /etc/fonts/conf.d/20-fix-globaladvance.conf O /usr/share/X11/locale/compose.dir 6 O /etc/bash_completion.d/yast2-completion.sh 7 R 6 0 1 R 7 0 1 C 7 R 6 1 6 C 6
(stat /usr/lib/libvorbis.so.0, "read whole small file" /etc/fonts/conf.d/20-fix-globaladvance.conf, open /usr/share/X11/locale/compose.dir as 6 and /etc/bash_completion.d/yast2-completion.sh as 7, read 1 block starting at ofs 0 from 6, one block starting at 0 from 7, close 7, read 6 blocks at 1 from file 6, close 6).
This now system specific file is the input to the /sbin/preload program (and stored in /var/cache/preload), which is run at strategic points in the startup process (e.g. a KDE session is preloaded while the KDM is still waiting for the username/password).
The sources for all of this are in the "preload" package. prepare_preload and update_preload are perl script, so you can look at them in the installed system. preload and print-bmap are written in C.

