Difference between revisions of "Readahead-fedora"

From ArchWiki
Jump to: navigation, search
(Trimming down boot-times: Added a reason why modifying /etc/inittab could be a good idea.)
m (l18n)
(10 intermediate revisions by 4 users not shown)
Line 1: Line 1:
Readahead-fedora is originally developed by fedora, and contrary to [http://wiki.archlinux.org/index.php/Ureadahead ureadahead] it doesn't require patching the kernel. It creates a list of files to put in the page cache before they're needed, thus reducing boot time.
+
[[Category:Boot process]]
 +
[[de:Readahead-fedora]]
 +
Readahead-fedora is originally developed by Fedora, and contrary to [[ureadahead]], it does not require patching the kernel. It creates a list of files to put in the page cache before they are needed, thus reducing boot time.
  
 
== Advantages ==
 
== Advantages ==
* It doesn't require patching the kernel.
+
* It does not require patching the kernel.
 
* It can take multiple lists of files to be preloaded, and sort them according to their position on the disk.
 
* It can take multiple lists of files to be preloaded, and sort them according to their position on the disk.
 
* It preloads the inode tables on ext2-based file systems.
 
* It preloads the inode tables on ext2-based file systems.
Line 10: Line 12:
  
 
== Installation ==
 
== Installation ==
[http://aur.archlinux.org/account.php?Action=AccountInfo&ID=20388 Ying] has created a PKGBUILD for this project, it can be found [http://aur.archlinux.org/packages.php?ID=40865 here].
+
Ying has created a [[PKGBUILD]] for this project; it is named {{AUR|readahead-fedora}} in the [[Arch User Repository|AUR]].
  
 
{{Note|libprelude currently doesn't build with libtool-2.4. Either downgrade to 2.2.10-3 or wait for a workaround.}}
 
{{Note|libprelude currently doesn't build with libtool-2.4. Either downgrade to 2.2.10-3 or wait for a workaround.}}
  
 
== Configuration ==
 
== Configuration ==
All configuration is done through /etc/readahead.conf. Some interesting variables might be:
+
All configuration is done through {{ic|/etc/readahead.conf}}. Some interesting variables might be:
 +
TIMEOUT_SWITCH_TO_LATER="8"
 +
This determines the timeout for the collector while X and such is starting.
 
  RAC_MAXTIME="100"
 
  RAC_MAXTIME="100"
 
A value in seconds that determine how long the collector should run.
 
A value in seconds that determine how long the collector should run.
Line 23: Line 27:
 
If you want the collector to ignore syscalls from certain programs, this is where you set their paths.
 
If you want the collector to ignore syscalls from certain programs, this is where you set their paths.
 
  RAC_EXCLUDE="/proc /sys /dev /var/log /var/run /var/lock /home /tmp /var/tmp /media /selinux /mnt"
 
  RAC_EXCLUDE="/proc /sys /dev /var/log /var/run /var/lock /home /tmp /var/tmp /media /selinux /mnt"
Directories to ignore while collecting. Anything that isn't needed during boot should probably be here to keep the list slimmed down.
+
Directories to ignore while collecting. Anything that is not needed during boot should probably be here to keep the list slimmed down.
  
 
== Usage ==
 
== Usage ==
To automatically start readahead and update the list, create /etc/rc.d/functions.d/readahead and add this to the file:
+
The package installs the file {{ic|/etc/rc.d/functions.d/readahead}}. This file will automatically start readahead at the appropriate times, control the collector and all that.
  
#
+
If you have dbus installed, readahead will automatically start it before X starts to avoid any issues.
# File for starting readahead and readahead-collector
+
#
+
+
. /etc/readahead.conf
+
+
readahead-early() {
+
  if [ -e /.readahead ]; then
+
    stat_busy "Starting readahead-collector - collecting data"
+
      /sbin/readahead-collector
+
    stat_done
+
  else
+
    stat_busy "Starting readahead - early read"
+
      /sbin/readahead  /etc/readahead.d/*.early
+
    stat_done
+
  fi
+
}
+
+
readahead-later() {
+
  if [ -e /.readahead ]; then
+
      sleep 8
+
      touch /.switch-collector-to-later
+
      rm /.readahead
+
  else
+
    stat_busy "Starting readahead - later read"
+
      sleep 1.6
+
      /sbin/readahead  /etc/readahead.d/*.later
+
    stat_done
+
  fi
+
}
+
+
add_hook sysinit_start readahead-early
+
add_hook multi_start readahead-later
+
{{Note|This should be enabled by default in newer versions of the package.}}
+
{{Note|If this breaks console-kit in KDE, you might need to use sysinit_end instead of multi_start}}
+
  
Now all you have to do is
+
The file {{ic|/.readahead}} should automatically be created when installing the package. This is to let readahead-collector profile your system next boot.
$ touch /.readahead
+
to let readahead-collector profile your system next boot.
+
  
 
=== Automated profiling ===
 
=== Automated profiling ===
This is actually really easy. With the above function, just add a cron job that creates the file /.readahead every month or so.
+
This is actually really easy, just add a cron job that creates the file {{ic|/.readahead}} every month or so.
  
 
=== Manually reprofile the system ===
 
=== Manually reprofile the system ===
Line 79: Line 47:
  
 
== Trimming down boot-times ==
 
== Trimming down boot-times ==
You can move the following around in /etc/inittab to start X earlier. This can potentially '''cause some major issues'''. Use with care.
+
The package edits your inittab to take advantage of the early - later split in readahead-fedora. What it basically does is move these lines around:
 
  ...
 
  ...
 
  rc::sysinit:/etc/rc.sysinit
 
  rc::sysinit:/etc/rc.sysinit
Line 99: Line 67:
 
   
 
   
 
  # End of file
 
  # End of file
The idea of doing it this way is that readahead will put the needed X-stuff in the early cache. Thus, while X is starting it'll have time to read the later cache for starting the daemons.
+
{{Note|The old inittab is backed up as {{ic|/etc/inittab.backup}}.}}
 
+
  
You can also try the [http://aur.archlinux.org/packages.php?ID=37879 quick-boot] package in AUR. However, '''this could break your system if you don't know what you're doing'''. Use with '''caution'''.
+
The idea of doing it this way is that readahead will put the needed X-stuff in the early cache. Thus, while X is starting it will have time to read the later cache for starting the daemons.
 +
{{Note|Since we cannot have multi starting early, we cannot use :once: instead of :wait: to make boot asynchronous.}}
  
 
== Notes ==
 
== Notes ==
Line 114: Line 82:
 
   else
 
   else
 
  ...
 
  ...
Readahead-fedora uses two steps to read and create the cache, called "early" and "later". Why it does it this way is to have a small, neat cache that it initially reads. This basically contains the basic files needed to boot together with X. After it's read those files and started X, it reads the "later" cache for starting the various daemons and services. This way, it tries to be a bit smarter and dynamic in hiding load times.
+
Readahead-fedora uses two steps to read and create the cache, called "early" and "later". Why it does it this way is to have a small, neat cache that it initially reads. This basically contains the basic files needed to boot together with X. After it has read those files and started X, it reads the "later" cache for starting the various daemons and services. This way, it tries to be a bit smarter and dynamic in hiding load times.
  
 
== Links ==
 
== Links ==
 
*[https://fedorahosted.org/readahead/browser/README README] from fedorahosted.org
 
*[https://fedorahosted.org/readahead/browser/README README] from fedorahosted.org
*[http://packages.debian.org/unstable/readahead-fedora Package info] from the debian package tree.
+
*[http://packages.debian.org/unstable/readahead-fedora Package info] from the Debian package tree.
*[http://aur.archlinux.org/packages.php?ID=40865 readahead-fedora] on AUR.
+
*{{AUR|quick-boot}} in the AUR.
*[http://aur.archlinux.org/packages.php?ID=37879 quick-init] on AUR.
+
*[https://wiki.archlinux.de/title/Readahead-fedora Article by ying] in German.
*[https://wiki.archlinux.de/title/Readahead-fedora Article by ying] in german.
+

Revision as of 18:41, 3 December 2012

Readahead-fedora is originally developed by Fedora, and contrary to ureadahead, it does not require patching the kernel. It creates a list of files to put in the page cache before they are needed, thus reducing boot time.

Advantages

  • It does not require patching the kernel.
  • It can take multiple lists of files to be preloaded, and sort them according to their position on the disk.
  • It preloads the inode tables on ext2-based file systems.
  • It opens the files without making the system update their access time, therefore avoiding extra disk writes. (Though, this shouldn't matter when using relatime or noatime I think)
  • It uses a lightweight monitoring daemon.

(List shamelessly stolen from the debian package description, original here)

Installation

Ying has created a PKGBUILD for this project; it is named readahead-fedoraAUR in the AUR.

Note: libprelude currently doesn't build with libtool-2.4. Either downgrade to 2.2.10-3 or wait for a workaround.

Configuration

All configuration is done through /etc/readahead.conf. Some interesting variables might be:

TIMEOUT_SWITCH_TO_LATER="8"

This determines the timeout for the collector while X and such is starting.

RAC_MAXTIME="100"

A value in seconds that determine how long the collector should run.

RAC_INITPATH="/sbin/init"

A path to your init program. Change this if you use anything other than sysvinit.

RAC_EXECIGN="/sbin/readahead /usr/sbin/preload"

If you want the collector to ignore syscalls from certain programs, this is where you set their paths.

RAC_EXCLUDE="/proc /sys /dev /var/log /var/run /var/lock /home /tmp /var/tmp /media /selinux /mnt"

Directories to ignore while collecting. Anything that is not needed during boot should probably be here to keep the list slimmed down.

Usage

The package installs the file /etc/rc.d/functions.d/readahead. This file will automatically start readahead at the appropriate times, control the collector and all that.

If you have dbus installed, readahead will automatically start it before X starts to avoid any issues.

The file /.readahead should automatically be created when installing the package. This is to let readahead-collector profile your system next boot.

Automated profiling

This is actually really easy, just add a cron job that creates the file /.readahead every month or so.

Manually reprofile the system

There are two ways to do this, either just run

$ touch /.readahead

as root, or you can temporarily add

init=/sbin/readahead-collector

to the kernel line in your bootloader. You should also disable auditd, because auditd deletes all audit rules during boot, which is contraproductive for the collector. Now, you just need to reboot and let the collector profile your system.

Trimming down boot-times

The package edits your inittab to take advantage of the early - later split in readahead-fedora. What it basically does is move these lines around:

...
rc::sysinit:/etc/rc.sysinit
rs:S1:wait:/etc/rc.single
#rm:2345:wait:/etc/rc.multi
#rh:06:wait:/etc/rc.shutdown
#su:S:wait:/sbin/sulogin -p

...
# Example lines for starting a login manager
#x:5:respawn:/usr/bin/xdm -nodaemon
#x:5:respawn:/usr/sbin/gdm -nodaemon
#x:5:respawn:/usr/bin/kdm -nodaemon
#x:5:respawn:/usr/bin/slim >& /dev/null

rm:2345:wait:/etc/rc.multi > /dev/null
rh:06:wait:/etc/rc.shutdown
su:S:wait:/sbin/sulogin -p

# End of file
Note: The old inittab is backed up as /etc/inittab.backup.

The idea of doing it this way is that readahead will put the needed X-stuff in the early cache. Thus, while X is starting it will have time to read the later cache for starting the daemons.

Note: Since we cannot have multi starting early, we cannot use :once: instead of :wait: to make boot asynchronous.

Notes

You might wonder what this file does while profiling:

...
readahead-later() {
  if [ -e /.readahead ]; then
      sleep 8
      touch /.switch-collector-to-later
      rm /.readahead
  else
...

Readahead-fedora uses two steps to read and create the cache, called "early" and "later". Why it does it this way is to have a small, neat cache that it initially reads. This basically contains the basic files needed to boot together with X. After it has read those files and started X, it reads the "later" cache for starting the various daemons and services. This way, it tries to be a bit smarter and dynamic in hiding load times.

Links