My transmission client was hogging my machine. Then I realized I never really use process priorities for CPU and/or IO, which is actually a pretty bad thing, considering some processes just are there to get some job done, but don’t need priority at all. Then I realized I also never use it for backup and such, which could be a problem for the server I’m running the backup on.
I already knew of the
nice program, with which you can alter the CPU scheduling prioritization of processes.
nice usually prefixes a command to start it up with altered ‘niceness’:
$ nice -n 19 rsync -a ~ /net/share/backup
renice is used to alter an already running process’s niceness:
$ renice -n 19 -p $PID # where, of course $PID is de pid of the process you're altering
Pretty useful, and also pretty common knowledge, as far as I know. But then it dawned on me that CPU priority isn’t at all what’s useful here. You want I/O priority. So, a little googling lead me to
ionice – how inventive a name – with which you can alter process I/O prioritization. Awesome!
$ ionice -c 2 -n 4 -p 1234 # Give process 1234 "best effort" priority 4
You should read the man pages of
ionice to find out what the parameters mean (just because it’s a good habit to read man pages, and not blogs ;)), but the basic usage is as follows:
# start a process 'some command with arguments' with a niceness of 19. # 19 means lowest priority, -19 means highest nice -n 19 some command with arguments # The process with pid 1234 gets a new niceness of 10, provided you are either root, # or you are the owner of the process renice -n 10 -p 1234 # The process with pid 1234 gets "Idle" class priority, which means it only gets I/O access # when no other process needs it. ionice -p 1234 -c 3
iotop to monitor the usage of CPU and I/O usage respectively. From now on, I’ll be nice to the kernel and not let him figure out all the prioritization. Wow that’s cheesy 😮