linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: O(1) scheduler & interactivity improvements
@ 2003-06-23 23:32 John Bradford
  2003-06-24  4:13 ` Bill Davidsen
  0 siblings, 1 reply; 39+ messages in thread
From: John Bradford @ 2003-06-23 23:32 UTC (permalink / raw)
  To: davidsen, felipe_alfaro, john; +Cc: helgehaf, linux-kernel

> On 23 Jun 2003, Felipe Alfaro Solana wrote:
>
>
> > Maybe I have different a different idea of what "interactive" should be.
> > For me, an interactive process should have nearly-realtime response
> > times to user events. For example, if I click on a link in my web
> > browser's window, I want almost an immediate response:I want the process
> > to acknowledge the event, although it could be impossible to perform it
> > due to network latency, etc.
>
> > > The're interactive if the user is staring at / listening to the output.
> > 
> > Or the user is feeding events to it, for example, by dragging a window,
> > clicking the mouse or pressing keys. If a process has received user
> > input in the past, ir's pretty probable that the process is an
> > interactive one.
>
> I think this reflects what "feels good," better than how much or how long
> a process sleeps, or what CPU it uses.

Agreed.

> Consider that an interestion may be
> not only a keypress, but might be a audio buffer going ready for more
> data. Screen update without keypress is not as reliable an indicator IMHO.

Agreed.

> No claim that this is the only factor, but this seems a good way to
> identify processes doing interactive things. I think you have to identify
> things like serial ppp or terminal processes as well.
>
>
> On Mon, 23 Jun 2003, John Bradford wrote:
>
> > > Maybe I have different a different idea of what "interactive" should be.
> > 
> > [snip]
> > 
> > > moving windows around the screen do feel jerky and laggy at best
> > > when the machine is loaded. For a normal desktop usage, I prefer all
> > > my intensive tasks to start releasing more CPU cycles so moving a
> > > window around the desktop feels completely smooth
> > 
> > That's fine for a desktop box, but I wouldn't really want a heavily
> > loaded server to have database queries starved just because somebody
> > is scrolling through a log file, or moving windows about doing admin
> > work.
>
> <bias report, I do stuff on servers a lot> It might be that the total
> interactivity bonus should be set for a system, so that the admin trying
> to use and editor on a config file wouldn't have an unresponsive cursor,
> while a bunch of users doing similar things would get a smaller (perhaps
> tiny) bonus and not impact the server main application.
>
> Question for the VM gods, faced with memory pressure should the VM as well
> as the schedular be aware of interactivity and give a preference to those
> processes when deciding what to page out? The supreme court says it's okay
> to give preference as long as it's not a quota ;-)

Maybe we should give a quota.  When faced with 100% CPU usage,
non-server apps, (however you define that), can't, in total, have more
than 10% CPU, (but see * below).

> > The wordprocessor example is an interesting one - if the user is
> > changing fonts, re-flowing text and generally using it like a DTP
> > application, then I'd agree that it needs to have a more CPU.
> > 
> > If I was simply typing a letter, I wouldn't really care about
> > interactivity.  If I was using a heavily loaded server to do it,
> > (unlikely), I'd rather the wordprocessor was starved, and updated the
> > screen once per second, and gave more time to the server processes,
> > because I don't need the visual feedback to carry on typing.  Screen
> > updates are a waste of CPU in that instance - it might look nice, but
> > all it's doing is starving the CPU even more.
>
> I think what I said about limited preference applies here, OpenOffice on a
> server is (usually) misuse, but vi and tail should be nice to use!

Yeah, I was thinking of an admin doing web-based admin work, scrolling
through and re-sizing browser windows.  That will use up a non-trivial
amount of CPU, even on a fast box.  You _want_ choppy scrolling in that case.

> On 23 Jun 2003, Felipe Alfaro Solana wrote:
>
> > On Mon, 2003-06-23 at 12:50, John Bradford wrote:
>
> > > That's fine for a desktop box, but I wouldn't really want a heavily
> > > loaded server to have database queries starved just because somebody
> > > is scrolling through a log file, or moving windows about doing admin
> > > work.
> > 
> > I agree 100%... So this leads us to having two different set of
> > scheduler policies: for desktop usage, and for server usage. For desktop
> > usage, most of the apps need CPU bursts for a bried period of time. For
> > server usage, we want a more steady scheduling plan.
>
> If the total available boost shared among all interactive processes were
> limited, it might good response to a small user load on a server without
> hurting the server application performance, while allowing a desktop to
> have a large boost limit and let the other processes run on the leavings.

*

Is there any reason why we can't set a 90%/10% server/non-server CPU
limit, but make any application burstable to 100% for no longer than
10% of the time?  I.E. it would work analogously to a burstable
network pipe.

For example:

Let all server apps be called S's, and non-server apps NS's.  The
total number of non-server apps is E(NS).

So, any NS app can use 10% divided by E(NS), at any one time.  All the
time it is using less than that, it is putting time slices in the bit
bucket to draw on later, (up to a maximum).  Then, it can burst to 10%
until it's bit bucket runs out, at which point it has to remain at 10%
divided by E(NS).  Obviously E(NS) may change at any time, and if the
CPU utilisation of all S's is less than 90%, any NS app can use more
than 10%, and the bit buckets are ignored.  The bit buckets are only
relevant when S's are using 90% cpu.  S's don't have bit buckets, but
the sum CPU usage for all S's can always go up to 90%.  Of course you
_could_ schedule S's using bit buckets as well, but that is going
outside the current scope of what we were trying to achieve.

Basically, that would mean that applications:

* Can never starve server processes of CPU
* Are rewarded for being polite with their time slices, (I.E. only
  bursting when necessary).
* Cannot fake being interactive and enjoy excessive CPU for any length
  of time.

Interactive processes tend to be bursty - scrolling and resizing
windows, for example.  Obviously a 3D VR game is interactive and could
easily use 100% CPU, but using the scheduling outlined above, it would
never get excessive CPU, because it's bit bucket would never fill up.

> I am suspicious of any idea of a single knob to solve multiple complex
> problems, feel free to tell me it either won't work for common case
> {whatever}, or that it can't be implemented.
>
>
> On Mon, 23 Jun 2003, John Bradford wrote:
>
>
> > > Nah! I also think it'a waste of time, but Joe-end-user won't think the
> > > same. He'll have a better feeling using more CPU to refresh the screen
> > > at a faster rate, even when that's a waste of CPU cycles.
> > 
> > I totally agree, but it's really tempting to say that that's the
> > distribution's responsibility to renice the X server, and let the
> > kernel default to doing the Right Thing, which is to starve screen
> > refreshes in favour of 'real' work.
>
> Feeding keypress priority back to the user service process is a nasty
> problem.  Ideally it wouldn't take a hack on the X server to let the
> scheduler know what was happening, but if there's a good way to do that,
> as in "doesn't do the wrong thing a lot," I'm sure we wouldn't have this
> thread. 

John.

^ permalink raw reply	[flat|nested] 39+ messages in thread
* Re: O(1) scheduler & interactivity improvements
@ 2003-06-23 19:20 John Bradford
  0 siblings, 0 replies; 39+ messages in thread
From: John Bradford @ 2003-06-23 19:20 UTC (permalink / raw)
  To: felipe_alfaro, helgehaf; +Cc: john, linux-kernel

> > > Well, no, opaque window moving is fine if the CPU isn't at 100%.  If
> > > it is, I'd rather see choppy window movements than have a server
> > > application starved of CPU.  That's just my preference, though.
> > > 
> > That could be an interesting hack to a window manager -
> > don't start the move in opaque mode when the load is high.
>
> But there are so many window managers floating out there...

True, but FVWM is obviously the best :-).

John.

^ permalink raw reply	[flat|nested] 39+ messages in thread
* Re: O(1) scheduler & interactivity improvements
@ 2003-06-23 12:44 John Bradford
  2003-06-23 16:32 ` Helge Hafting
  2003-06-23 21:48 ` Bill Davidsen
  0 siblings, 2 replies; 39+ messages in thread
From: John Bradford @ 2003-06-23 12:44 UTC (permalink / raw)
  To: felipe_alfaro, john; +Cc: helgehaf, linux-kernel

> > > Maybe I have different a different idea of what "interactive" should be.
> > 
> > [snip]
> > 
> > > moving windows around the screen do feel jerky and laggy at best
> > > when the machine is loaded. For a normal desktop usage, I prefer all
> > > my intensive tasks to start releasing more CPU cycles so moving a
> > > window around the desktop feels completely smooth
> > 
> > That's fine for a desktop box, but I wouldn't really want a heavily
> > loaded server to have database queries starved just because somebody
> > is scrolling through a log file, or moving windows about doing admin
> > work.
>
> I agree 100%... So this leads us to having two different set of
> scheduler policies: for desktop usage, and for server usage. For desktop
> usage, most of the apps need CPU bursts for a bried period of time. For
> server usage, we want a more steady scheduling plan.

Unfortunately, what is good for a desktop box is often counter
productive for a server :-(

> > If I was simply typing a letter, I wouldn't really care about
> > interactivity.  If I was using a heavily loaded server to do it,
> > (unlikely), I'd rather the wordprocessor was starved, and updated the
> > screen once per second, and gave more time to the server processes,
> > because I don't need the visual feedback to carry on typing.  Screen
> > updates are a waste of CPU in that instance - it might look nice, but
> > all it's doing is starving the CPU even more.
>
> So, opaque window moving is also a waste of time and we'd better stick
> to border-only (transparent) window moving ;-)

Well, no, opaque window moving is fine if the CPU isn't at 100%.  If
it is, I'd rather see choppy window movements than have a server
application starved of CPU.  That's just my preference, though.

> Nah! I also think it'a waste of time, but Joe-end-user won't think the
> same. He'll have a better feeling using more CPU to refresh the screen
> at a faster rate, even when that's a waste of CPU cycles.

I totally agree, but it's really tempting to say that that's the
distribution's responsibility to renice the X server, and let the
kernel default to doing the Right Thing, which is to starve screen
refreshes in favour of 'real' work.

Of course, people who are running X on a server for admin tasks could
always renice their X server to a lower priority to achieve a similar
effect.

> > I propose a radically different approach to scheduling, why not
> > favour processes that cause the fewest cache faults?  I.E. if a
> > process that gets more done in it's timeslice is more deserving of
> > it.  It might look ugly with screen updates being starved, but it
> > would probably get more work done :-).
>
> What would happen with poorly written programs? There are a lot of them
> that don't take advantage of memory locality, are not designed to fully
> utilize the cache, or use arrays in a way that produces too much
> page/cache faults.

Those programs are broken by design :-), (especially on NUMA
hardware).

I was just thinking that with cache-friendly processes being given a
bigger timeslice, we wouldn't be filling the cache with irrelevant
data so often.

John.

^ permalink raw reply	[flat|nested] 39+ messages in thread
* Re: O(1) scheduler & interactivity improvements
@ 2003-06-23 10:50 John Bradford
  2003-06-23 11:22 ` Felipe Alfaro Solana
  2003-06-23 11:36 ` Denis Vlasenko
  0 siblings, 2 replies; 39+ messages in thread
From: John Bradford @ 2003-06-23 10:50 UTC (permalink / raw)
  To: felipe_alfaro, helgehaf; +Cc: linux-kernel

> Maybe I have different a different idea of what "interactive" should be.

[snip]

> moving windows around the screen do feel jerky and laggy at best
> when the machine is loaded. For a normal desktop usage, I prefer all
> my intensive tasks to start releasing more CPU cycles so moving a
> window around the desktop feels completely smooth

That's fine for a desktop box, but I wouldn't really want a heavily
loaded server to have database queries starved just because somebody
is scrolling through a log file, or moving windows about doing admin
work.

The wordprocessor example is an interesting one - if the user is
changing fonts, re-flowing text and generally using it like a DTP
application, then I'd agree that it needs to have a more CPU.

If I was simply typing a letter, I wouldn't really care about
interactivity.  If I was using a heavily loaded server to do it,
(unlikely), I'd rather the wordprocessor was starved, and updated the
screen once per second, and gave more time to the server processes,
because I don't need the visual feedback to carry on typing.  Screen
updates are a waste of CPU in that instance - it might look nice, but
all it's doing is starving the CPU even more.

I propose a radically different approach to scheduling, why not
favour processes that cause the fewest cache faults?  I.E. if a
process that gets more done in it's timeslice is more deserving of
it.  It might look ugly with screen updates being starved, but it
would probably get more work done :-).

John.

^ permalink raw reply	[flat|nested] 39+ messages in thread
* O(1) scheduler & interactivity improvements
@ 2003-06-22 16:07 Felipe Alfaro Solana
  2003-06-22 20:00 ` Davide Libenzi
  2003-06-23  8:09 ` Helge Hafting
  0 siblings, 2 replies; 39+ messages in thread
From: Felipe Alfaro Solana @ 2003-06-22 16:07 UTC (permalink / raw)
  To: LKML

Hi all,

I must say I'm a little bit disappointed with the interactive feeling of
latest kernels. From what I have read, it seems the scheduler decides on
the "interactive" behavior of a process based on its CPU usage and
sleeping times. I am no kernel expert, so I will assume this is how it
works, more or less, behind the scenes.

I think that marking a process as "interactive" based on the previous
premise is quite unreal. Let's take, for example, a real application
like a word processor which performs background spell checking. The word
processor should be considered interactive, even when it may be hogging
the CPU a lot to perform the background spell check and the rest of its
threads are sleeping waiting for user input.

As someone said before in the list, a process should be marked
"interactive" based on the fact that it's receiving user input, for
example, key strokes, mouse movements or any events received from any
input device, not based on its CPU usage. I think applications like XMMS
or mplayer shouldn't be considered interactive (at least, not until they
start interacting with user), and they have a constant usage of CPU.
However, interactive applications have peaks, requiring shots of CPU for
very short times. However, that's not necessarily true, as I said before
with the example of the word processor: it could well be wasting 100% of
CPU to perform spellchecking but it should still be considered an
interactive application: a single user keystroke should take preference
over the background spellchecking.

For terminal based, interactive applications (like pine, vi, and
company), which are connected to tty devices, a user input event could
make the scheduler boost the process priority for a brief time (and
then, reduce the priority in a nearly quadratic fashion until reaching
it's original, or a lower, priority) to give it a better response time
and increase the interactive feeling.

However, for X11 based applications it seems a lot more difficult since
all user-based input events are received by the X server itself (and not
the process for which the event is intended). Based on the previous
thoughts, the X11 server would be marked interactive, but not the
application (like the word processor). This is not the desired effect.

So the question is, how can we detect the ultimate process for which the
user input event is intended? Should the X11 server help the scheduler
by increasing the target process priority (it normally runs as root)?
Should the window manager increase the priority of the process which
owns the current foreground, active window? Solaris seems to work this
way: when the user changes the focus to a new window, the window owner
is brought into the interactive scheduling class. When the user chooses
a new window, the window which loses the focus forces its owner to
return to the time-shared scheduling class.

What do you think about all of this? Should we use behavior-based
against CPU-usage behavior to decide process interactivity?

Thanks for listening.


^ permalink raw reply	[flat|nested] 39+ messages in thread

end of thread, other threads:[~2003-06-30 13:30 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-23 23:32 O(1) scheduler & interactivity improvements John Bradford
2003-06-24  4:13 ` Bill Davidsen
  -- strict thread matches above, loose matches on Subject: below --
2003-06-23 19:20 John Bradford
2003-06-23 12:44 John Bradford
2003-06-23 16:32 ` Helge Hafting
2003-06-23 19:00   ` Felipe Alfaro Solana
2003-06-23 19:17     ` Helge Hafting
2003-06-24 22:41   ` Timothy Miller
2003-06-25 21:42     ` Helge Hafting
2003-06-25 23:16       ` Timothy Miller
2003-06-23 21:48 ` Bill Davidsen
2003-06-23 10:50 John Bradford
2003-06-23 11:22 ` Felipe Alfaro Solana
2003-06-23 11:36 ` Denis Vlasenko
2003-06-22 16:07 Felipe Alfaro Solana
2003-06-22 20:00 ` Davide Libenzi
2003-06-23 12:50   ` Jesse Pollard
2003-06-23  8:09 ` Helge Hafting
2003-06-23 10:18   ` Felipe Alfaro Solana
2003-06-23 16:21     ` Daniel Gryniewicz
2003-06-23 18:59       ` Felipe Alfaro Solana
2003-06-23 16:47     ` Helge Hafting
2003-06-24 18:12       ` Bill Davidsen
2003-06-25 21:41         ` Helge Hafting
     [not found]       ` <5.2.0.9.2.20030624215008.00ce73b8@pop.gmx.net>
2003-06-26  9:59         ` Helge Hafting
2003-06-26 10:39           ` Mike Galbraith
2003-06-26 14:50           ` Bill Davidsen
2003-06-26 23:10           ` Timothy Miller
     [not found]           ` <Pine.LNX.3.96.1030626104733.17562D-100000@gatekeeper.tmr.c om>
2003-06-27  6:36             ` Mike Galbraith
2003-06-27  8:18               ` Helge Hafting
2003-06-27  9:46                 ` Mike Galbraith
2003-06-27 11:39                   ` Helge Hafting
2003-06-27 12:18                     ` Mike Galbraith
2003-06-28  3:51                   ` Bill Davidsen
     [not found]                   ` <Pine.LNX.3.96.1030627234408.25848A-100000@gatekeeper.tmr.c om>
2003-06-28  5:44                     ` Mike Galbraith
2003-06-28 14:34                       ` Helge Hafting
2003-06-29  6:08                         ` Mike Galbraith
2003-06-30 13:37                       ` Bill Davidsen
2003-06-27  6:54           ` jw schultz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).