20 November 2010

Faster Linux in a Few Simple Steps!

A 200-line Linux kernel patch has been developed, that is designed to automatically create task groups per TTY in an effort to improve the desktop interactivity under system strain.

Lennart Poettering, a RedHat developer, has come up with an easy alternative (it takes just a few simple steps) to this patch. The following method for Ubuntu users is provided, courtesy of Ricardo Ferreira:


Start by editing your rc.local file, running sudo gedit /etc/rc.local and add the following lines above "exit 0":

mkdir -p /dev/cgroup/cpu
mount -t cgroup cgroup /dev/cgroup/cpu -o cpu
mkdir -m 0777 /dev/cgroup/cpu/user
echo "/usr/local/sbin/cgroup_clean" > /dev/cgroup/cpu/release_agent

Save and exit gedit. Now, make it executable:

sudo chmod +x /etc/rc.local

After doing this, edit the .bashrc file found in your home directory (gedit ~/.bashrc) and, at the end of this file, add:

if [ "$PS1" ] ; then
mkdir -m 0700 /dev/cgroup/cpu/user/$$
echo $$ > /dev/cgroup/cpu/user/$$/tasks
echo "1" > /dev/cgroup/cpu/user/$$/notify_on_release
fi

One last thing. To make sure that cgroups are deleted whenever the last task leaves, run:

sudo gedit /usr/local/sbin/cgroup_clean

And copy-paste this:

#!/bin/sh
rmdir /dev/cgroup/cpu/$*

Once again, save the file, exit gedit and make it executable:

sudo chmod +x /usr/local/sbin/cgroup_clean

Done! Restart your computer to apply the changes.

No comments: