Preload

Preload is an daemon that monitors which programs you use most often. And when the system is idle it loads them into memory, speeding up their startup times when you do run them.

Installation is simple as its in most distribution's main repositories, just grab with your favorite package manager (it's usually called preload).

Now, to get it to work there are two ways you can do it (at least in Arch). The easiest way is just to add it to your daemons list in your rc.conf so that it starts on boot even before you log in. But the larger a preload database you have (the more programs you use) the slower your boot will be.

Some people can live with the trade off of a slow boot for fast app startup but I've spent way too much time trimming that whole process to turn back now. But there's another way to enjoy the benefits of preload while still booting lightning quick. Loading it at login, where there's less system critical things running at the same time.

If you try to launch the preload daemon normally it won't work, because it needs to be run as root. And just putting sudo in front of it won't work either because there's no where to enter our password. So we tell Linux that it doesn't need a password to launch preload. We do this with visudo. This app lets you safely edit your /etc/sudoers file by making sure you use the correct syntax.

I added an entry to allow everyone in the users group to launch /etc/rc.d/preload without the need of a password. The comments in the sudoers file should be enough to let you do the same.

If you haven't guessed by the name, visudo does its text editing with vi, a pretty confusing program to someone that hasn't used it before. Vi has 2 modes 'Command Mode' (in which you start) and 'Insert Mode' (the editing mode that people are more familiar with). If you're unsure of how to use vi, here's a handy cheat sheet.

Create the following script and add it to your startup applications:

#!/bin/bash
sudo /etc/rc.d/preload start


That's it. Enjoy preload! To see how it works and some pretty graphs showing how effective it can be, check out this great explanation.


EDIT: I've been doing some more testing (sitting in front of my computer with a stop watch) and as long as the preload daemon is backgrounded at boot, it's actually faster to load than doing the same at login. I made my laptop automatically log me in and timed from when I pushed the power button until my wicd tray icon showed an internet connection. 'Boot Preload' usually beat 'Login Preload' by 2-3 seconds.

0 comments:

Post a Comment