Wednesday, November 17, 2010

Small kernel patch gives Linux a significant speed boost

With just 233 lines of code to the Kernel's scheduler, Mike Galbraith (a Linux Kernel developer) has cut desktop latency by a factor of TEN...

What does the patch do?

Mike Galbraith explains:
Each task’s signal struct contains an inherited pointer to a refcounted autogroup struct containing a task group pointer, the default for all tasks pointing to the init_task_group. When a task calls __proc_set_tty(), the process wide reference to the default group is dropped, a new task group is created, and the process is moved into the new task group. Children thereafter inherit this task group, and increase it’s refcount. On exit, a reference to the current task group is dropped when the last reference to each signal struct is dropped. The task group is destroyed when the last signal struct referencing it is freed. At runqueue selection time, If a task has no cgroup assignment, it’s current autogroup is used.
Phoronix has a pair of videos, the first running the auto-group scheduler disabled and the second with it enabled. The test is running a web browser, HD video and compiling a kernel.

Auto-group scheduler disabled

Auto-group scheduler enabled

The patch even impressed Linus Torvalds who mentions:
It’s an improvement for things like smooth scrolling around, but what I found more interesting was how it seems to really make web pages load a lot faster. Maybe it shouldn’t have been surprising, but I always associated that with network performance. But there’s clearly enough of a CPU load when loading a new web page that if you have a load average of 50+ at the same time, you _will_ be starved for CPU in the loading process, and probably won’t get all the http requests out quickly enough.
So I think this is firmly one of those “real improvement” patches. Good job. Group scheduling goes from “useful for some specific server loads” to “that’s a killer feature”.
It's a little late to get the patch merged into the 2.6.37 kernel, but it should be merged into the 2.6.38 kernel. Of course you can always apply the patch yourself and rebuild your kernel, you'll need to patch kernel source 2.6.37-rc2 (you can get it from

Source OMG! Ubuntu


No comments:

Post a Comment