Prelink
Most programs require libraries to function. Libraries can be integrated into a program once, by a linker, when it is compiled (static linking) or they can be integrated when the program is run by a loader, (dynamic linking). Dynamic linking has advantages in code size and management, but every time a program is run, the loader needs to find the relevant libraries. Because the libraries can move around in memory, this causes a performance penalty, and the more libraries that need to be resolved, the greater the penalty. Prelink reduces this penalty by using the system's dynamic linker to reversibly perform this linking in advance ("prelinking" the executable file) by relocating. Afterward, the program only needs to spend time finding the relevant libraries on being run if, for some reason (perhaps an upgrade), the libraries have changed since being prelinked.
Contents
Installing
Install the prelinkAUR package.
Configuration
All settings are in /etc/prelink.conf
.
Usage
Prelinking
The following command prelinks all the binaries in the directories given by /etc/prelink.conf:
# prelink -amR
Exclude list
Taken from the discussion page:
/etc/prelink.conf
# Skype -b /usr/lib32/skype/skype -b /usr/lib/skype/skype # Flash Player Plugin -b /usr/lib/mozilla/plugins/libflashplayer.so # NVIDIA -b /usr/lib/libGL.so* -b /usr/lib32/libGL.so* -b //usr/lib/libOpenCL.so* -b //usr/lib32/libOpenCL.so* -b /usr/lib32/vdpau/ -b /usr/lib/vdpau/ -b /usr/lib/xorg/modules/drivers/nvidia_drv.so -b /usr/lib/xorg/modules/extensions/libglx.so* -b /usr/lib/libnvidia-* -b /usr/lib32/libnvidia-* # Catalyst -b /usr/lib/libati* -b /usr/lib/fglrx* -b /usr/lib/libAMDXvBA* -b /usr/lib/libGL.so* -b /usr/lib/libfglrx* -b /usr/lib/xorg/modules/dri/fglrx_dri.so -b /usr/lib/xorg/modules/drivers/fglrx_drv.so -b /usr/lib/xorg/modules/extensions/fglrx/ -b /usr/lib/xorg/modules/linux/libfglrxdrm.so -b /usr/lib/xorg/modules/extensions/libglx.so
Removing prelink
Remove prelinking from all binaries:
# prelink -au
Daily cron job
This is recommended (and included in other distros packages) as it has to be done in order to get speed benefits from updates. Save as /etc/cron.daily/prelink
/etc/cron.daily/prelink
#!/bin/bash [[ -x /usr/bin/prelink ]] && /usr/bin/prelink -amR &>/dev/null
and give it the necessary ownership and permissions:
# chmod 755 /etc/cron.daily/prelink
Alternatively, there's a prelink-systemdAUR package in the AUR that installs a daily systemd timer unit with the same effect as the above cron script.
KDE
KDE knows about prelinking and it will start faster if you tell it you have it. It is best to stick this in where all the users can use it.
/etc/profile.d/kde-is-prelinked.sh
export KDE_IS_PRELINKED=1
and give it the necessary ownership and permissions:
# chmod 755 /etc/profile.d/kde-is-prelinked.sh