==> My desktop starts to lags... opening a console takes way too much time....
If you already experience this, here comes a tip to keep a pleasant desktop: messing with io priorities...
As usual, this is not garanteed, if you break something, get hacked, loose your job or even start to miss windows, don't complain to me
So, let's start !
Check kernel settings:
* Be sure you have a PREEMT enabled kernel
Code: Select all
$ zcat /proc/config.gz | grep PREEMT
# CONFIG_PREEMPT_NONE is not set
CONFIG_PREEMPT_VOLUNTARY=y
# CONFIG_PREEMPT is not set
* be sure CFQ iosched is enabled
Code: Select all
$ zcat /proc/config.gz | grep IOSCHED
CONFIG_IOSCHED_NOOP=y
CONFIG_IOSCHED_AS=y
CONFIG_IOSCHED_DEADLINE=y
CONFIG_IOSCHED_CFQ=y
CONFIG_DEFAULT_IOSCHED="anticipatory"
add to /etc/conf.d/local.start:
Code: Select all
for drive in /sys/block/*/queue/scheduler
do
echo cfq > $drive
done
* install ionice
a) get the source from kernel docs:
Code: Select all
sed -n -e "/snip ionice.c/,/snip ionice.c/ p" /usr/src/linux/Documentation/block/ioprio.txt | sed "s/.\+snip ionice.\+//g" > ionice.c
b) Patch it => create a file called ionice.patch and copy the following content
Code: Select all
--- ionice.c.ori 2006-05-14 13:59:53.000000000 +0200
+++ ionice.c 2006-05-14 13:56:32.000000000 +0200
@@ -1,5 +1,3 @@
-
-
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
@@ -99,14 +97,23 @@
printf("%s: prio %d\n", to_prio[ioprio_class], ioprio);
}
} else {
+ if (getuid()!=0 && (ioprio_class < IOPRIO_CLASS_BE || ioprio < 4) ) {
+ fprintf(stderr,"User cannot set higher ioprio\n");
+ return 1;
+ }
if (ioprio_set(IOPRIO_WHO_PROCESS, pid, ioprio | ioprio_class << IOPRIO_CLASS_SHIFT) == -1) {
perror("ioprio_set");
return 1;
}
- if (argv[optind])
+ if (argv[optind]) {
+ if (seteuid(getuid())!=0 || setegid(getgid())!=0) {
+ perror("Error setting real user");
+ return 1;
+ }
execvp(argv[optind], &argv[optind]);
}
+ }
return 0;
}
Code: Select all
patch --dry-run -l < ionice.patch
Code: Select all
patch -l < ionice.patch
Code: Select all
gcc -o ionice ionice.c
Code: Select all
# chown root:root ionice && chmod u+s,-rw ionice
Code: Select all
# mv ionice /usr/bin
I use ionice on every heavy io cron jobs.... Simply change the cron job scripts (/etc/cron.*) to prefix the calls to program with ionice...( do some backups first...
Some infos:
* Can be used with nice
* 3 prio:
RT (real time) ==> -c1 (take it no matter what)
BE (BEST EFFORT)==> -c2 (default)
IDLE ==> -c3 (disk will be used only if "free")
* Level: available for RT and BE, use via -nX
Levels allows you a finer tunning of the class (prio between same class) - this is not used for idle...
Default prio are BE level 4
Check /usr/src/linux/Documentation/block/ioprio.txt for more info
Examples
eg: Start an emerge sync as low priorities
Code: Select all
# ionice -c3 emerge --sync
Code: Select all
#! /bin/sh
if [ -x /usr/bin/updatedb ]
then
if [ -f /etc/updatedb.conf ]
then
/usr/bin/ionice -c3 nice /usr/bin/updatedb
else
/usr/bin/ionice -c3 nice /usr/bin/updatedb -f proc
fi
chown root:locate /var/lib/slocate/slocate.db
fi





