LWN.net Logo

Fixing interactive response in 2.6

While the performance improvements in the 2.6 kernel have impressed and pleased many users, there has been a constant level of complaining about the scheduler. In particular, many users are unhappy with the interactive feel of the 2.6 kernel; reports of jerky response and skipping audio are common. Some have gone as far as to compare the 2.6-test scheduler with the 2.4 virtual memory subsystem at the same point in the development cycle. There is some concern that scheduling could be one of the (few) embarrassments in the upcoming 2.6.0 release. Those worries are probably overdone, but the point is that 2.6.0-test scheduling still needs some work.

The good news is that said work is being done. Con Kolivas has been posting a set of interactivity patches for about a month now. Those wanting to try them out can find them in a recent -mm kernel; patches against the Linus kernels can be found on Con's web site. His most recent patch is 011int.

Con's work follows a familiar theme: improve interactive performance by giving a priority boost to interactive processes. All you have to do is figure out which processes are the interactive ones. Of course, that is rather easier said than done. Con's interactivity patches have been through several iterations in an attempt to find the best way to identify interactive processes and the proper amount of bonus to give them. This patch series may be converging on a result; several testers have reported good results.

The core idea (already part of the 2.6.0-test scheduler) is that an interactive process is one which sleeps much of the time. With Con's patches, any process which sleeps for at least one clock tick gets a priority bonus when it wakes up; processes which have done enough sleeping recently to be explicitly marked as "interactive" get a bigger bonus than others. Processes which run without sleeping for their entire time slice lose a point. In this way, CPU-hog processes sink to the lowest priorities, while a process reading from a terminal (or an audio stream) will get quick access to the processor. Additionally, processes which have maxed out their sleep bonus and are seen as truly interactive can hang out in the run queue for a while even after their time slice expires.

Life is not always so simple, however. Early versions of this patch tended to make life hard for newborn processes; it took them quite a while to build up enough of an interactivity bonus to be able to respond quickly on a loaded system. So things had to be tweaked to let new processes find their natural level quickly. There is also the issue of processes that sleep for a long time, then wake up to do some serious cranking. So processes that sleep for longer than one second lose their interactivity bonus, and end up at an "idle" level just below the interactive level. Work has also been required to balance priorities properly when an interactive process forks.

More recently, Ingo Molnar has also started looking at the interactivity problem; his sched-2.6.0-test1-G6 patch takes a different approach. Ingo starts by changing the scheduler to use nanosecond resolution in its timekeeping; his claim is that, by working with high-resolution time, audio skipping problems can be fixed. Then, the patch splits up time slices so that processes running at the same priority switch off with each other much more often, ensuring that none of them have to wait too long before getting some processor time. Finally, Ingo's patch extends the sleep bonus to include time that the process sits in the run queue, but does not actually get into the processor.

The two sets of patches are mostly orthogonal to each other; while it remains hard to apply both Con's and Ingo's patches to a single system, the two really are addressing different issues. Recent versions of Con's patches, however, also include some of Ingo's work (almost everything except the nanosecond resolution). In the end, code from both patches is likely to find its way into the kernel.

As a postscript, it's worth taking a look at this post from Daniel Phillips, where he states that the wrong approach is being taken for the audio skipping problem. Audio playback, says Daniel, is not an interactive task - it is a realtime task. What is really needed for the audio case is a bounded-latency soft realtime scheduler, not an endless series of interactive scheduler tweaks.


(Log in to post comments)

Fixing interactive response in 2.6

Posted Jul 31, 2003 3:45 UTC (Thu) by Peter (guest, #1127) [Link]

His most recent patch is 011int.

Everyone seems to make this mistake. It's O11int, not 011int. I don't know the significance of the big-oh (we're not doing complexity analysis, after all), but that's what Con has been calling these things.

Fixing interactive response in 2.6

Posted Jul 31, 2003 17:08 UTC (Thu) by cpeterso (guest, #305) [Link]

I have no idea why Con is calling his patch series "-O#int". I guess int stands for interactive, but what about the O? He used to maintain a "-ck#" patch series and that naming scheme seems a lot simpler to me.

Big oh

Posted Aug 1, 2003 16:23 UTC (Fri) by giraffedata (subscriber, #1954) [Link]

I don't know the significance of the big-oh (we're not doing complexity analysis, after all)

Yes, I believe we're doing complexity analysis. My understanding is that O(1) refers to the fact that the time it takes the scheduler to choose a process to run does not vary with the number of processes there are. By contrast, an O(n) scheduler might run down the list of processes looking for the best one to run.

Big oh

Posted Aug 3, 2003 6:43 UTC (Sun) by Peter (guest, #1127) [Link]

Yes, I believe we're doing complexity analysis. My understanding is that O(1) refers to

Yes, I know what an O(1) scheduler is. (Sheesh, give me a little credit.) What I don't know is why an O11int scheduler would be called an O11int scheduler (other than the obvious fact that it came after the O10int scheduler). The big-oh here is clearly not referring to an asymptotic worst-case runtime.

Ingo Molnar uses a combination of letter + number to designate different versions of his patches. Perhaps Con is doing the same thing. But, maybe I'm just not paying attention, but I never saw the A through N series of interactivity patches.

Fixing interactive response in 2.6

Posted Aug 4, 2003 23:28 UTC (Mon) by daniel (subscriber, #3181) [Link]

"I don't know the significance of the big-oh (we're not doing complexity analysis, after all), but that's what Con has been calling these things."

Though I never asked Con, it's evident that the O1 refers to the 2.5/6 scheduler, and "int" refers to addressing its interactivity shortcomings.

not scheduler related?

Posted Jul 31, 2003 17:12 UTC (Thu) by cpeterso (guest, #305) [Link]

Earlier this week, Con posted on LKML that he thinks the problem is not (entirely) related to the new scheduler.

Re: Ingo Molnar and Con Kolivas 2.6 scheduler patches:

"It has become obvious that the problems with interactivity that have evolved in 2.5 are not scheduler related. Just try plugging in all the old 2.4 O(1) scheduler settings into the current scheduler and you will see that it still performs badly. What exactly is the cause is a mystery but seems to be more a combination of factors with a careful look at the way the vm behaves being part of that."

link

Posted Jul 31, 2003 19:29 UTC (Thu) by tjc (subscriber, #137) [Link]

Some background information, for those interested:

http://www.tldp.org/LDP/LG/issue89/vinayak2.html

Why don't they just go back to the old scheduler?

Posted Aug 2, 2003 6:43 UTC (Sat) by miallen (guest, #10195) [Link]

If the "new" scheduler didn't work then shouldn't it be yanked? And all the patches described sound like they're just masking the problem. Why should a modern machine have any problem playing audio when you could do it just fine with earily 2.4 kernels? This is very depressing. I have noticed I can start typing my password before su is ready for it since mid 2.4. I think it's obvious where this is headed. We can't claim Linux is so lean anymore.

Copyright © 2003, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds
Powered by Rackspace Managed Hosting.