Speed up application launches with prelink

Application start up times can be annoying if they are really really slow. Part of this latency is a process where before the executable can run, the OS needs to work out which libraries it needs to kick into action.

This process of working out the right libraries can take maybe even several seconds on slower machines and complex apps and can be a big source of slowdowns on application starts.

That's where prelink comes in. What prelink does is it pre-calculates which libraries are needed for certain applications and caches this information so that it can be retrieved quickly.

Quick disclaimer - prelinking is quite a powerful tool and thus if you do it wrong you could end up not being able to start important programs. If you're going to set up prelinking, let the process run the whole way through. Setting it up also needs a little bit of Linux know-how. You have been warned.

A Gentoo howto explains the process well:

“Most common applications make use of shared libraries. These shared libraries need to be loaded into memory at runtime and the various symbol references need to be resolved. For most small programs this dynamic linking is very quick. But for programs written in C++ and that have many library dependencies, the dynamic linking can take a fair amount of time.

“On most systems, libraries are not changed very often and when a program is run, the operations taken to link the program are the same every time. Prelink takes advantage of this by carrying out the linking and storing it in the executable, in effect prelinking it.

“Prelinking can cut the startup times of applications. For example, a typical KDE program’s loading time can be cut by as much as 50%. The only maintenance required is re-running prelink every time a library is upgraded for a pre-linked executable.”

On Fedora Core 6, prelink is actually built right in and is set up to work out of the box, so you should already get the speed advantages on application booting. However, you can force the system to re-prelink all the applications on your system using the instructions below.

For other distributions, you can set up prelinking by following these steps:

  1. Use your package manager to install the prelink package if it isn't already.
  2. Edit the file /etc/default/prelink so it contains the line - PRELINKING=yes
  3. As root, run the daily script manually - /etc/cron.daily/prelink

After that, prelinking should automatically run every day and hopefully you'll notice a bit of speed up.

For some more advanced instructions on using prelinking, go to this page and scroll down to the prelinking section. You can also find distro-specific hints and tips by searching for distro name prelink in your favourite search engine.

Avatar for peter Peter Upfold - http://peter.upfold.org.uk/

Peter Upfold is a technology enthusiast from the UK. Peter’s interest in Linux stems back to 2003, when curiosity got the better of him and he began using SUSE 9.0. Now he runs Linux Mint 9 on the desktop, runs a CentOS-based web server from home for his personal website and dabbles in all sorts of technology things across the Windows, Mac and open source worlds.

Home » Articles »

Discussion: Speed up application launches with prelink

Home » Articles » Speed up application launches with prelink