Tuesday, November 23, 2010

Forget 200 lines, Red Hat speeds up Linux with 4 lines of code

Speeding up Linux, doesn't necessarily have to be a gargantuan task and it doesn't have to be done by Linus Torvalds either.

On Monday, Torvalds praised a new 200 line Linux kernel patch that was going to make Linux faster for all. Inside of the same week, a new userspace patch has emerged that can likely do the same thing, but with less code and even better performance.
"I really wonder why logic like this should live in kernel space at all,since a) the kernel has no real notion of a session, except audit and b) this is policy and as soon as people have this kind of group then they probably want other kind of autogrouping as well for the other controllers, which hence means userspace is a better, and configurable place for this."Red Hat developer Lennart Poettering wrote in a Linux Kernel Mailing list posting.

Torvalds (always the diplomat) responded:
Numbers talk, bullshit walks. The numbers have been quoted. The clear interactive behavior has been seen. And you're just full of bullshit. Come back when you have something working and with numbers and better interactive performance. Until then, nobody cares.

To his credit Poettering did come back with a response to prove Torvalds wrong. Poettering provided a non kernelspace patch that speeds up Linux systems. The patch involved a simple edit of a users ~/.bashrc file with four new lines of code.

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


Then, as the superuser do this:

 mount -t cgroup cgroup /sys/fs/cgroup/cpu -o cpu
 mkdir -m 0777 /sys/fs/cgroup/cpu/user

"Done. Same effect. However: not crazy," Poettering wrote.


That's not however the end of the story. As Torvalds (never one to give up a good fight) has shot back again at Poettering. In Torvalds view, the difference between the Red Hat engineer's userspace 4 line patch and the 200 line patch in the Linux kernel, is a question of automation.

Read more: InternetNews.com