SUPER preloading internals
From openSUSE
This page gives some technical details about preloading. It is intended for developers rather than the average user.
Contents |
Preload Program itself
The core of the entire preloading is /sbin/preload which reads instructions of what files to preload from stdin. Preload then uses the posix_fadvise system call to tell the kernel that a certain file will soon be used. The kernel reacts to this by loading the file into the filesystem cache. For more detail about posix_fadvise have a look at "man posix_fadvise". The preload binary and the other programs mentionned here are part of the "preload" package that is installed by default.
Infrastructure around preload
What files need to be preloaded for a certain application can be seen in the files in /etc/preload.d. Note that some entries start with "open", others with "stat". Open means that the content needs to be preloaded, stat means that this file will just be statted by the preload program. Note that e.g. OpenOffice stats 338 files, so this does have an impact.
However, these lists are in no particular order (some are alphabetical, some not). In order to be fed to preload, they need to be processed by /usr/bin/prepare_preload. To be honest, I have no idea according to which criteria these get reordered. But I guess they are being sorted according to their physical position on the hard disk, to allow even faster reading of the files. Fixme: Someone who knows for sure please correct me if I'm wrong. Anyway, there is no need to know how exactly this works if you want to use preloading. It works, that's all that counts. Prepare_preload stores the new lists in /var/cache/preload/.
The lists in /var/cache/preload/ will be updated when your system is shut down. The script /etc/init.d/boot.preload_early calls /usr/bin/update_preload. You can also call update_preload manually when you changed anything in /etc/preload.d/.
Usage of preloading
There are currently 4 different places where preloading is used:
- During booting, the scripts boot.preload and boot.preload_early in /etc/init.d/ preload some files that will be used during bootup.
- Before login, /etc/init.d/earlykdm (package kdebase3-kdm) preloads the files necessary for kdm and KDE.
- While login screen is shown, /opt/kde3/share/config/kdm/kdmrc (package kdebase3-SuSE) makes sure KDE get preloaded. Seems a bit redundant, I'll ask Stephan Kulow.
- After login to KDE, /opt/kde3/share/autostart/appspreload.desktop will call /usr/bin/appspreloader.sh. For WMs other than KDE, there is currently no preloading. But on my original page about preloading you can find a little hack to fix that.
The inner workings of PePr
When you call pepr_update.sh it will strace all your processes (including forked processes), saving the output in ~/.pepr/tmp. Once you pressed ENTER it will stop stracing and analyze what files have been opened/statted. This list is then processed by prepare_preload and the final output appended to ~/.pepr/preloadfile. The autostart entry in /opt/kde3/share/autostart/ will do the preloading once the user starts KDE.

