LowPriorityIOforBackgroundTasks

Please check the status of this specification in Launchpad before editing it. If it is Approved, contact the Assignee or another knowledgeable person before making changes.

Summary

CFQ disk scheduler allows assigning priorities for disk I/O separately for each process. This can be used to assign lowest priority to disk intensive background tasks (like updating slocate database, file indexing in Beagle or installing packages in Synaptic) in order to improve responsiveness and desktop experience for user.

Rationale

While CFQ scheduler (made default in Edgy) is performing quite well and improved experience a lot over anticipatory scheduler, it still has some impact on using apps and gives impression of sloppiness. By assigning class "idle" to background task (tested with updating slocate database) the impact is practically invisible.

Use cases

  • Joe plays his favorite game at night and updating slocate database kicks in, making his game appear sloppy for several minutes. Using low priority IO for updating slocate database he does not even notice anything happened.
  • Jane browses her pictures while system updates are installed in the background. This causes intensive disk I/O and pictures appear with noticeable delay. When using low priority I/O for apt, she does not notice anything, so updates can be even installed automatically in the background.
  • John burns a CD, when Beagle starts indexing files and causes his burning process to empty queue and produce broken CD, so Joe is angry. Using low priority I/O his indexing process would not be able to starve ISO image generation and burning would succeed.

Scope

Design

  • Setting IO priority is as easy as running ionice utility, included in schedutils package. IO priority is inherited during fork, so it can be applied to whole groups of processes.
  • Scripts for running background tasks should be modified to run command prefixed with "ionice -c 3" (unfortunately ionice utility does not have any docs, but -c 3 means "set class to idle").
  • Apps (like Synaptic or Adept) should be run also prefixed with ionice utility, or they should be modified to run "apt" using ionice. Alternatively, apt can be replaced with simple script which runs "ionice -c 3 apt $@" or similar.

Implementation

  • schedutils package must be moved to Main installed by default (currently it is in Universe).
  • Slocate can be changed by modifying /etc/cron.daily/slocate script.
  • Beagle can be changed by modifying /etc/cron.daily/beagle-crawl-system script.
  • Adept and synaptic can be changed by modifying "Exec" field in /usr/share/applications/kde/adept.desktop or /usr/share/applications/synaptic.desktop (respectively).

Code

Data preservation and migration

Unresolved issues

  • Changing io class to "idle" requires administrator privileges. All use cases above should be doable, as they are run with root privileges, but some additional use cases might come up when processes are run as user. This could be solved by providing special SUID binary (after security audit) which would only allow changing class of own processes and only to idle class.

BoF agenda and discussion

  • Allowing non-root users to set idle would allow some denial of service attacks. See https://bugzilla.novell.com/show_bug.cgi?id=147944 . I don't see any point in allowing non-root users to set -c3 without first benchmarking -c3 v.s. -n7 (which non-root users can already set). --JohnMccabeDansted

  • Perhaps setting nice should automatically set ionice to something like -n7. People who really didn't want this behavior could always run "nice ionice -n0" to get the old behavior of nice. However, I imagine that most users would find a single nice command for all forms of niceness convenient. --JohnMccabeDansted

  • O_STREAMING could also be used to reduce Beagle's tendency to flood the cache. Perhaps we could also have a related "syshint" proposal, see: http://makarevitch.org/rant/bufchint.html --JohnMccabeDansted


CategorySpec

LowPriorityIOforBackgroundTasks (last edited 2008-08-06 16:24:28 by localhost)