Search My Blog

Friday, November 19, 2010

Forget 200 lines, Red Hat speeds up Linux with 4 lines of code - InternetNews:The Blog - Sean Michael Kerner

Netstat -vat by Sean Michael Kerner (bio)

A command line view of IT



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

By Sean Michael Kerner on November 19, 2010 8:17 AM

From the 'NO BS' files:

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.

According to Torvalds, if the patch is in the kernel, it will be enable for all Linux users automatically.
"If the choice is between telling everybody "you should do this", and"we should just do this for you", I'll take the second one every time.We know it should be done. Why should we then tell somebody else to do it for us?" Torvalds wrote.
Having this type of performance improvement in the kernel, does make a lot of sense to me as it could extend the benefits to all, as Torvalds suggests. It leads to a broader argument about what should or shouldn't be in kernel-space vs userspace. Enabling all Lonux distribution by default is the right decision for the Linux kernel, though I can see how and where a distribution might want to do better through userspace improvements.

Ultimately though, whether this performance boost is in userspace or the kernel, Linux users win.


Go there...
http://blog.internetnews.com/skerner/2010/11/forget-200-lines-red-hat-speed.html

Don

No comments: