Package: preload
Version: 0.4-4
Followup-For: Bug #439901

Hi, I'm attaching a simple patch to preload init.d script in order to
have it run at idle priority, i.e. so as to exploit the default CFQ
scheduler of Linux >= 2.6.13 in order to use only idle disk bandwidth.
This seems to optimize performances, by reducing system load and improve
general responsiviness.

Thanks!
--
a.m.

-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 2.6.23.1
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages preload depends on:
ii  libc6                         2.6.1-6    GNU C Library: Shared libraries
ii  libglib2.0-0                  2.14.2-1   The GLib library of C routines

preload recommends no packages.

-- no debconf information
--- debian/init.d       2007-10-29 08:47:52.000000000 +0100
+++ /etc/init.d/preload 2007-10-29 08:47:29.000000000 +0100
@@ -18,6 +18,7 @@
 NAME=preload
 DESC=preload
 DAEMON_OPTS="-s /var/lib/preload/preload.state $DAEMON_OPTS"
+SCHEDULER="/usr/bin/ionice"
 
 test -x $DAEMON || exit 0
 
@@ -26,12 +27,25 @@
        . /etc/default/preload
 fi
 
+#
+# Lower system load by running at idle priority if possible
+# Requires kernel >= 2.6.13 with CFQ scheduler and package util-linux
+#
+
+if [ -x $SCHEDULER ] ; then
+       echo "Ionice scheduler found; running at idle priority"
+       RUNAS="$SCHEDULER -c3"
+else
+       echo "Ionice scheduler not found and/or kernel version < 2.6.13."
+       echo "Consider upgrading and/or installing package util-linux"
+fi
+
 set -e
 
 case "$1" in
   start)
        echo -n "Starting $DESC: "
-       if start-stop-daemon --start --quiet -u 0 --exec $DAEMON -- 
$DAEMON_OPTS ; then
+       if start-stop-daemon --start --quiet -u 0 --exec $RUNAS $DAEMON -- 
$DAEMON_OPTS ; then
            echo "$NAME."
        else
            echo "already running."

Reply via email to