Install readahead-list on ArchLinux

According to freshmeat:

readahead-list allows users to load files into the page cache before they are needed, to accelerate program loading. It improves on the existing readahead by taking the name of a file with the items to load, instead of requiring the arguments being passed as parameters. Additionally, it contains a tool (filelist-order) to optimize the order of the file list in several possible ways.

I am picking the source file from ubuntu/debian because it also includes a tool to “record filesystem events” and generate the list of files to load. Grab the source and the diff here from launchpad

extract it:

gzip -d readahead-list*.diff.gz
tar -xzf readahead-list*.tar.gz

patch it:

patch -p1 < readahead-list*.diff
cd readahead-list*/
#be sure to apply all the patches in the patches directory:
patch -p1 < ../debian/patches/05*
patch -p1 < ../debian/patches/10*
patch -p1 < ../debian/patches/50*
patch -p1 < ../debian/patches/51*

compile:

#please choose the appropriate prefix:
./configure --prefix=/usr
make
#(as root)
make install

Hopefully everything is compiled. There might be some error messages, but as long as the process did not error out, everything should be ok.

Now for the system setup. The way I think it ought to go is record the startup in two parts, the boot, and the desktop. The boot part will record and load all files related to general startup. The desktop part will load everything from after the system startup (including graphical login manager) to when the default session type is loaded (i.e. kde desktop). The following files and directories need to be created:

#technically, this contents might make this directory better place in /var but /etc will do
mkdir /etc/readahead
touch /etc/readahead/boot
touch /etc/readahead/desktop
#the following can be duplicated for each section, if you want it handled by rc
touch /etc/rc.d/readahead-list-desktop
touch /etc/rc.d/readahead-watch-desktop

To record the first part, we need to stop the graphical login manager from loading, so we login via the command line interface. This is done by editing the DAEMONS section of /etc/rc.conf by adding an ! before kdm, or gdm, etc. Then we need to start the record as early as we can in the boot process. This is technically done by creating a script, and then using the init= parameter on the kernel line of grub. For this tutorial, we will put the lines of code in /etc/rc.sysint. Insert some lines to make the top of the file look like this:

#!/bin/bash
#
# /etc/rc.sysinit
#

echo "starting readahead-watch..."
/usr/sbin/readahead-watch -o /etc/readahead/boot
echo "readahead is watching..."

#echo "reading files..."
#/usr/sbin/readahead-list /etc/readahead/boot &amp;

. /etc/rc.conf
. /etc/rc.d/functions

Line 7 is the import one above. This will record all files loaded after the command is run, on any device and save the list to the specified file. After you login, to kill the process run:

ps ax | grep readahead
#as root
kill $PID

The boot section has now been recorded. Now the files /etc/rc.d/ will look like:

#!/bin/bash
#readahead-watch-desktop
/usr/sbin/readahead-watch -o /etc/readahead/desktop
#!/bin/bash
#readahead-list-desktop
/usr/sbin/readahead-list /etc/readahead/desktop

With these files in place, edit the daemon section in the rc.conf to include readahead-watch-desktop before the login manager, and do NOT background it. Reboot the computer, and kill the process in the same was as before after you have logged in (Note: this will record a terminal instance in the file. You can avoid this by hitting something like ALT-F6 to login textually). After you have stopped the recording, edit the daemons section to instead start readahead-list-desktop.

Here are my results.


the results are kind of dismal in the pure timing end, as observable by bootchart only two seconds shorter. But I have never seen my desktop load faster! If I didn’t have the resource heavy services such as klipper, guidance-power-manager or network-manager it would load in a blink.

Play around with the placement of the readahead-list command, just make sure you start a recording from the same place. This placement of the rc.d file is kind of cheating, because it relies on the lag in response time of the user login to load files in the background, but it still makes a heck of a difference. Also, if you always start up firefox or something when you login, record that too and it will start a little faster.

About these ads

About this entry