linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Osterlund <petero2@telia.com>
To: Con Kolivas <kernel@kolivas.org>
Cc: Tim Connors <tconnors+linuxkernel1073186591@astro.swin.edu.au>,
	linux-kernel@vger.kernel.org
Subject: Re: xterm scrolling speed - scheduling weirdness in 2.6 ?!
Date: 06 Jan 2004 02:09:56 +0100	[thread overview]
Message-ID: <m2ptdxq3vf.fsf@telia.com> (raw)
In-Reply-To: <200401041658.57796.kernel@kolivas.org>

Con Kolivas <kernel@kolivas.org> writes:

> On Sun, 4 Jan 2004 14:32, Tim Connors wrote:
> > > Not quite. The scheduler retains high priority for X for longer so it's
> > > no new dynamic adjustment of any sort, just better cpu usage by X (which
> > > is why it's smoother now at nice 0 than previously).
> > >
> > > > If either the scheduler or xterm was a bit smarter or
> > > > used different thresholds, the problem would go away. It would also
> > > > explain why there are people who cannot reproduce it. Perhaps a
> > > > somewhat faster or slower system makes the problem go away. Honnestly,
> > > > it's the first time that I notice that my xterms are jump-scrolling, it
> > > > was so much fluid anyway.
> > >
> > > Very thorough but not a scheduler problem as far as I'm concerned. Can
> > > you not disable smooth scrolling and force jump scrolling?
> >
> > AFAIK the definition of jump scrolling is that if xterm is falling
> > behind, it jumps. Jump scrolling is enabled by default.
> >
> > What this slowness means is that xterm is getting CPU at just the
> > right moments that it isn't falling behind, so it doesn't jump - which
> > means X gets all the CPU to redraw, which means your ls/dmesg anything
> > else that reads from disk[1] doesn't get any CPU.
> >
> > Xterm is already functioning as designed - you can't force jump
> > scrolling to jump more - it is at the mercy of how it gets
> > scheduled. If there is nothing more in the pipe to draw, it has to
> > draw.
> >
> > These bloody interactive changes to make X more responsive are at the
> > expense of anything that does *real* work.
> 
> Harsh words considering it is the timing sensitive nature of xterm that relies 
> on X running out of steam in the old scheduler design to appear smooth.

But the scheduler is also far from fair in this situation. If I run

        perl -e 'for(;;){printf("ddddddddddddddddddddddddddd\n");}'

in an xterm, the system enters a steady state where top shows:

Cpu(s): 78.3% us, 20.9% sy,  0.0% ni,  0.0% id,  0.0% wa,  0.0% hi,  0.9% si
Mem:     61660k total,    60544k used,     1116k free,     4568k buffers
Swap:   104824k total,    22064k used,    82760k free,    17596k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 2562 root      15   0 17284 7088 7664 S 39.2 11.5   3:21.20 X
 2755 petero    15   0  5652 3260 4528 S 31.7  5.3   1:53.89 xterm
 2808 petero    25   0  3424 1248 2744 R  3.9  2.0   0:01.71 perl
 2807 petero    16   0  1764  940 1636 R  1.6  1.5   0:00.87 top

What happens is that X and xterm start with highest possible
interactivity credit and CURRENT_BONUS, because they were mostly idle
before the test started. The perl program starts at some PR>15 and
slowly climbs to 25. Its interactivity credit remains at 0. As soon as
the perl process delivers one line of output to xterm, xterm and later
X are scheduled, because they have a smaller priority value than
perl. When they have finished scrolling one line, perl is scheduled
again and produces another line of output.

However, since X and xterm both have HIGH_CREDIT and CURRENT_BONUS ==
MAX_BONUS, they only get charged 1/10th of their runtime, because of
this code in schedule():

	if (HIGH_CREDIT(prev))
		run_time /= (CURRENT_BONUS(prev) ? : 1);

Since both processes spend approximately 50% of their time sleeping,
the sleep_avg increase in recalc_task_prio() is more than enough to
keep the processes at maximum interactivity level forever.

The situation for the perl process is that it always loses the cpu a
short time before it would voluntarily go to sleep. The perl process
gets approximately 4% cpu, but it wants 4+epsilon percent cpu, so it
is considered a cpu hog, and eventually gets maximum punishment
(PR=25).

The end result is that the perl process, which requires very little
cpu time, is considered a cpu hog, and the two real cpu hogs (X and
xterm) are considered interactive. This is not a transient state. The
situation does not go away until I kill the perl process or start some
other cpu hog to disturb the scheduler.

-- 
Peter Osterlund - petero2@telia.com
http://w1.894.telia.com/~u89404340

  reply	other threads:[~2004-01-06  1:15 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <Pine.LNX.4.44.0401031439060.24942-100000@coffee.psychology.mcmaster.ca>
2004-01-03 20:19 ` xterm scrolling speed - scheduling weirdness in 2.6 ?! Soeren Sonnenburg
2004-01-03 21:00   ` Con Kolivas
2004-01-03 21:10     ` Soeren Sonnenburg
2004-01-03 21:15       ` Con Kolivas
2004-01-03 23:35         ` Willy Tarreau
2004-01-04  0:11           ` Soeren Sonnenburg
2004-01-04  1:42           ` Con Kolivas
2004-01-04  3:32             ` Tim Connors
2004-01-04  5:58               ` Con Kolivas
2004-01-06  1:09                 ` Peter Osterlund [this message]
2004-01-06  1:37                   ` Nick Piggin
2004-01-06  2:28                     ` Peter Osterlund
2004-01-06  2:50                       ` Nick Piggin
2004-01-06  6:27                       ` Nick Piggin
2004-01-05 22:25               ` Bryan Whitehead
2004-01-04  8:09             ` Soeren Sonnenburg
2004-01-04  8:49               ` Con Kolivas
2004-01-04 11:13                 ` Martin Schlemmer
2004-01-04 11:24                   ` Soeren Sonnenburg
2004-01-04 12:45                   ` Con Kolivas
2004-01-04 14:42                     ` Martin Schlemmer
2004-01-04 18:40                       ` mikeg
2004-01-04 22:58                       ` szonyi calin
2004-01-04 23:33                         ` Willy Tarreau
2004-01-04 23:44                           ` Valdis.Kletnieks
2004-01-04 23:47                           ` Mike Fedyk
2004-01-05  8:39                             ` Soeren Sonnenburg
2004-01-05 20:38                               ` Martin Schlemmer
2004-01-05  9:18                             ` Soeren Sonnenburg
2004-01-05 17:20                               ` Martin Schlemmer
2004-01-05 17:21                                 ` Willy Tarreau
2004-01-05  9:50                             ` Kenneth Johansson
2004-01-05 10:17                               ` Soeren Sonnenburg
2004-04-02 18:22                               ` solved (was Re: xterm scrolling speed - scheduling weirdness in 2.6 ?!) Soeren Sonnenburg
2004-04-03  5:35                                 ` Tim Connors
2004-04-03  6:06                                   ` Tim Connors
2004-04-03 14:11                                     ` Jamie Lokier
2004-01-05  8:26                         ` xterm scrolling speed - scheduling weirdness in 2.6 ?! Soeren Sonnenburg
2004-01-04  8:54               ` Lincoln Dale
2004-01-04  9:17                 ` Nick Piggin
2004-01-04 10:24                   ` Soeren Sonnenburg
2004-01-04 11:12                     ` Mike Fedyk
2004-01-04 11:17                       ` Soeren Sonnenburg
2004-01-04 11:20                         ` Mike Fedyk
2004-01-04 11:19                       ` Willy Tarreau
2004-01-05  0:48                         ` Nick Piggin
2004-01-04 11:46                   ` Nicks's scheduler's OK [was Re: xterm scrolling speed - scheduling weirdness in 2.6 ?!] Willy Tarreau
2004-01-04 12:07                   ` xterm scrolling speed - scheduling weirdness in 2.6 ?! Willy Tarreau
2004-01-05  0:51                     ` Nick Piggin
2004-01-05 18:37                       ` Willy Tarreau
2004-01-06  0:33                         ` Nick Piggin
2004-01-04 10:11                 ` Soeren Sonnenburg
2004-01-05 10:31                   ` venom
2004-01-03 21:18     ` Willy Tarreau
2004-01-03 21:39 Bob Gill
     [not found] <Pine.LNX.4.44.0401031402210.24942-100000@coffee.psychology.mcmaster.ca>
2004-01-03 19:07 ` Soeren Sonnenburg
  -- strict thread matches above, loose matches on Subject: below --
2004-01-03 18:52 Soeren Sonnenburg
2004-01-03 19:19 ` Willy Tarreau
2004-01-04 20:47   ` Peter Chubb
2004-01-04 20:54     ` Willy TARREAU
2004-01-05  3:46       ` Peter Chubb

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2ptdxq3vf.fsf@telia.com \
    --to=petero2@telia.com \
    --cc=kernel@kolivas.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tconnors+linuxkernel1073186591@astro.swin.edu.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).