I think that the hiccup problem is not necessarily caused by swapping. If a program is playing something, Linux should notice this and not swap it. Programs that don't do much are the first ones that get swapped. You can check if the program is really getting swapped by looking at the RSS
/RES
field from ps or top. RSS
is the resident set size, the non-swapped physical memory that a task is using (in kiloBytes).
I think that your problem is most probably caused by improper CPU and I/O scheduling and a bit of inefficiency of Rhythmbox which makes it sensitive to high system loads. The CPU priority can be changed with the commands nice and renice. The I/O priority can be changed with the ionice command. Only the super user can use high priorities. You should also know that Linux kernel guys are trying to improve the responsiveness of desktop systems with various low-latency patches, so you might consider using them. One of them is a ~200 lines patch written by Mike Galbraith which has impressed even Linus. The alternative to this patch is Lennart Poettering's cgroups trick which I think will be the default in Fedora 15.
Anyway, without those patches there are two options: start the program with a high priority or change it afterwards. For the first option you could use a wrapper script around Rhythmbox:
#!/bin/sh
# Run Rhytmbox with high CPU and I/O priorities
nice -n -10 ionice -c 1 -n 1 su -l -c rhythmbox alexei
You will need to run it as root. If you don't want to login as root just to start this, you can use either su
or sudo
.
As for changing the priority afterwards, if you're too lazy to login as root to change it, you could try using a cron job that runs every 5 minutes and sets the priority of the rhythmbox
process, but I wouldn't recommend doing this:
#!/bin/sh
renice -n -10 -p `pidof rhythmbox`
ionice -c 1 -n 1 -p `pidof rhythmbox`
ps
ortop
to see if rhytmbox is really swapped by checking theRSS
/RES
field? I think that your problem is mostly caused by improper scheduling. You should try torenice
the rhytmbox process or change some of its settings, e.g. the size of the audio buffer.