From Fedora Project Wiki

Readahead reloaded

If you compare a non-readahead bootchart with a readahead bootchart , you can clearly see, that most of the services are bound to disk I/O.

There are 2 existing "readahead/prefetching" helpers in Fedora.

Ubuntu may switch to prefetch ( https://wiki.ubuntu.com/DesktopTeam/Specs/Prefetch ) but that requires a non-standard kernel module (I don't think, that it makes it upstream).

Preload is adaptive, but gathers information by scanning /proc every 20s. Comparisons showed, that readahead performs better in the boot phase before login.

Readahead modifications

  • readahead_early starts before udev in rc.sysinit, reads files needed until gdm login.
  • readahead_later starts when the login window is displayed, reads files needed from login until xxx seconds after login.
  • readahead-collector runs every boot in the background and automatically adapts the readahead files to the boot sequence and usage profile of the user in the first xxx seconds.

Testcase

boot, login, start firefox, close firefox

Numbers in seconds taken from the bootcharts.

[1] [2] [3]
Desktop-1 61 56 9%
Desktop-2 52 42 24%
Laptop 100 91 10%
[1]
without readahead: from start of rc.sysinit until closing of firefox
[2]
with readahead: from start of rc.sysinit until closing of firefox
[3]
speedup: = [1] / [2] - 1
Desktop-1
Default install from livecd, normal disk
Desktop-2
customized, fast RAID-1 disk (90MB/s)
Laptop
customized, slow disk

Positive Side effects

  • Desktop reacts to mouse clicks immediately after icons are visible.
  • Firefox loads faster.
  • Slicker desktop experience

Problems

  • if readahead-early is started right after starting the collector, the collector hasn't initialized yet and does not start the early phase recording, because early already started without it noticing
  • triggering readahead-later _exactly_ on login prompt display is not yet possible
  • readahead-collector conflicts with auditd, because auditd resets all audit rules
  • readahead-collector receives all audit events for readahead (overhead), but ignores them later
  • on a really slow disk system, with services optimized, readahead may be an overhead

Todo

gdm/kdm

  • gdm/kdm needs an option to run a command (/sbin/readahead_later_start) exactly when the login window is visible to the user

readahead

  • readahead-collector delays the start of auditd now Done
    • systemtap is not an option (needs kernel-debuginfo)
    • wrote a systemtap script to gather data, to determine, what readahead-collector needs http://harald.fedorapeople.org/readahead-collector.stp )
    • strace cannot trace init and reimplementing strace for all archs in upstart does not seem reasonable
    • wrote an auditd patch (would contradict the auditd use case to store anything on disk immediately) not needed anymore
  • readahead-collector needs to run nicely at the end (readlink() bomb) Done
  • readahead-collector needs to generate the sorted file list at the end Done
  • readahead-collector should not overwrite the old file list, if killed before xxx seconds (fast reboot/shutdown after bootup) Done
  • readahead-collector should not wait on readahead-early to start recording for the early phase Done
  • readahead-later needs a trigger mechanism from gdm to start (/sbin/readahead_later_start) Done
  • RAC_EXCLUDE="/proc /sys /dev /var/log /var/run /var/lock /home /tmp" needs to be customized Done
  • remove readahead initscripts Done
  • readahead-early should be started by upstart Done

Outcome

  • even better numbers :-)