linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: george anzinger <george@mvista.com>
To: Jamie Lokier <lk@tantalophile.demon.co.uk>
Cc: Ben Greear <greearb@candelatech.com>, Bret Indrelee <bret@io.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	high-res-timers-discourse@lists.sourceforge.net
Subject: Re: No 100 HZ timer!
Date: Fri, 13 Apr 2001 09:07:04 -0700	[thread overview]
Message-ID: <3AD72428.CBA4F2B7@mvista.com> (raw)
In-Reply-To: <Pine.LNX.4.21.0104122258060.7396-100000@fnord.io.com> <3AD69D7F.36B2BA87@candelatech.com> <3AD6BBDD.D5BA23EE@mvista.com> <20010413123612.A30971@pcep-jamie.cern.ch>

Jamie Lokier wrote:
> 
> george anzinger wrote:
> > > Wouldn't a heap be a good data structure for a list of timers?  Insertion
> > > is log(n) and finding the one with the least time is O(1), ie pop off the
> > > front....  It can be implemented in an array which should help cache
> > > coherency and all those other things they talked about in school :)
> > >
> > I must be missing something here.  You get log(n) from what?  B-trees?
> > How would you manage them to get the needed balance?  Stopping the world
> > to re-balance is worse than the cascade.  I guess I need to read up on
> > this stuff.  A good pointer would be much appreciated.
> 
> Look for "priority queues" and "heaps".  In its simplest form, you use a
> heap-ordered tree, which can be implemented using an array (that's
> usually how it's presented), or having the objects in the heap point to
> each other.
> 
> A heap-ordered tree is not as strictly ordered as, well, an ordered tree
> :-)  The rule is: if A is the parent of B and C, then A expires earlier
> than B, and A expires earlier than C.  There is no constraint on the
> relative expiry times of B and C.
> 
> There is no "stop the world" to rebalance, which you may consider an
> advantage over the present hierarchy of tables.  On the other hand, each
> insertion or deletion operation takes O(log n) time, where n is the
> number of items in the queue.  Although fairly fast, this bound can be
> improved if you know the typical insertion/deletion patterns, to O(1)
> for selected cases.  Also you should know that not all priority queues
> are based on heap-ordered trees.
> 
> Linux' current hierarchy of tables is a good example of optimisation: it
> is optimised for inserting and actually running short term timers, as
> well as inserting and deleting (before running) long term timers.  These
> extremes take O(1) for insertion, removal and expiry, including the
> "stop the world" time.  This should be considered before and move to a
> heap-based priority queue, which may turn out slower.
> 
> > Meanwhile, I keep thinking of a simple doubly linked list in time
> > order.  To speed it up keep an array of pointers to the first N whole
> > jiffie points and maybe pointers to coarser points beyond the first N.
> > Make N, say 512.  Build the pointers as needed.  This should give
> > something like O(n/N) insertion and O(1) removal.
> 
> You've just described the same as the current implementation, but with
> lists for longer term timers.  I.e. slower.  With your coarser points,
> you have to sort the front elements of the coarse list into a fine one
> from time to time.
> 
> The idea of having jiffie-point pointers into a data structure for fast
> insertion is a good one for speeding up any data structure for that
> common case, though.
> 
If we are to do high-res-timers, I think we will always have to do some
sort of a sort on insert.  If we can keep the sort to a VERY short list
and only do it on sub jiffie timers, we will have something that is VERY
close to what we have now.

I think that the density of timers tends to increase as they get closer
to "now".  This should allow coarser pointers for times more removed
from "now".  Still if we sort on insert we will not have to resort
later.

The pointers into the list, however, are perishable and need to be
refreshed as time passes.  My though was to do this only when a needed
pointer was found to be "expired" and then only for the needed pointer. 
On first need we would have a small overhead, but would remember for
next time.

Thanks for the good input

George

  reply	other threads:[~2001-04-13 16:09 UTC|newest]

Thread overview: 118+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-11 17:56 No 100 HZ timer! Bret Indrelee
2001-04-12 17:39 ` george anzinger
2001-04-12 21:19   ` Bret Indrelee
2001-04-12 22:20     ` george anzinger
2001-04-13  4:00       ` Bret Indrelee
2001-04-13  6:32         ` Ben Greear
2001-04-13  8:42           ` george anzinger
2001-04-13 10:36             ` Jamie Lokier
2001-04-13 16:07               ` george anzinger [this message]
2001-04-13 23:00                 ` Jamie Lokier
2001-04-13 12:05           ` Horst von Brand
2001-04-13 21:53             ` george anzinger
2001-04-13 23:10               ` Jamie Lokier
2001-04-16  3:02                 ` Ben Greear
2001-04-16  2:46                   ` Jamie Lokier
2001-04-16 12:36                     ` Mark Salisbury
2001-04-16 19:19                       ` george anzinger
2001-04-16 20:45                         ` Albert D. Cahalan
2001-04-16 21:29                           ` Chris Wedgwood
2001-04-16 22:25                           ` george anzinger
2001-04-16 23:57                         ` Mark Salisbury
2001-04-17  0:45                           ` george anzinger
2001-04-17 12:12                             ` Mark Salisbury
2001-04-17 12:51                         ` Mark Salisbury
2001-04-17 18:53                           ` george anzinger
2001-04-17 19:41                             ` Jamie Lokier
2001-04-23  8:05                             ` Ulrich Windl
2001-04-23 13:22                               ` Mark Salisbury
2001-04-16  2:41               ` Ben Greear
  -- strict thread matches above, loose matches on Subject: below --
2001-08-01 17:22 No 100 HZ timer ! george anzinger
2001-08-01 19:34 ` Chris Friesen
2001-08-01 19:49   ` Richard B. Johnson
2001-08-01 20:08     ` Mark Salisbury
2001-08-01 20:33     ` george anzinger
2001-08-01 21:20   ` george anzinger
2001-08-02  4:28     ` Rik van Riel
2001-08-02  6:03       ` george anzinger
2001-08-02 14:39         ` Oliver Xymoron
2001-08-02 16:36           ` george anzinger
2001-08-02 17:05             ` Oliver Xymoron
2001-08-02 17:46               ` george anzinger
2001-08-02 18:41                 ` Oliver Xymoron
2001-08-02 21:18                   ` george anzinger
2001-08-02 22:09                     ` Oliver Xymoron
2001-08-02 17:26             ` John Alvord
2001-04-12 13:14 No 100 HZ timer! Bret Indrelee
2001-04-12 12:58 No 100 HZ timer ! Mark Salisbury
2001-04-11  9:06 schwidefsky
2001-04-10 14:42 schwidefsky
2001-04-10 12:54 schwidefsky
2001-04-10 11:38 schwidefsky
2001-04-10 11:54 ` Alan Cox
2001-04-10  7:29 schwidefsky
2001-04-10  7:27 schwidefsky
2001-04-09 15:54 schwidefsky
2001-04-09 18:30 ` Jeff Dike
2001-04-09 18:19   ` Mark Salisbury
2001-04-09 20:12     ` Alan Cox
2001-04-09 20:32       ` Mark Salisbury
2001-04-09 22:31       ` Mikulas Patocka
2001-04-09 22:35         ` Alan Cox
2001-04-10 11:43           ` David Schleef
2001-04-10 12:04             ` Mikulas Patocka
2001-04-10 12:31               ` David Schleef
2001-04-10 12:34                 ` Mark Salisbury
2001-04-10 14:10                 ` Mikulas Patocka
2001-04-10 13:35                   ` root
2001-04-10 14:22                   ` Andi Kleen
2001-04-10 15:43                   ` Alan Cox
2001-04-12  5:25                     ` watermodem
2001-04-12  8:45                       ` Jamie Lokier
2001-04-10 17:15                   ` Jamie Lokier
2001-04-10 17:27                     ` Alan Cox
2001-04-10 17:35                       ` Jamie Lokier
2001-04-10 18:17                         ` Alan Cox
2001-04-10 18:24                           ` Jamie Lokier
2001-04-10 19:28                             ` george anzinger
2001-04-10 20:02                               ` mark salisbury
2001-04-10 22:08                                 ` george anzinger
2001-04-11  0:48                                   ` Mark Salisbury
2001-04-11  2:35                                     ` george anzinger
2001-04-12  0:24                                       ` Mark Salisbury
2001-04-11 16:11                                     ` Jamie Lokier
2001-04-11 16:59                                       ` george anzinger
2001-04-11 18:57                                         ` Jamie Lokier
2001-04-11 19:21                                           ` John Alvord
2001-04-12  8:41                                             ` Jamie Lokier
2001-08-01  1:08                               ` george anzinger
2001-08-11 11:57                                 ` Pavel Machek
2001-08-14 15:59                                   ` Jamie Lokier
2001-08-14 16:57                                     ` george anzinger
2001-04-10 19:50                             ` Zdenek Kabelac
2001-04-11 11:42                               ` Maciej W. Rozycki
2001-04-11 16:13                                 ` Jamie Lokier
2001-04-12  9:51                                   ` Maciej W. Rozycki
2001-04-10 19:42                       ` Zdenek Kabelac
2001-04-10 12:19             ` Mark Salisbury
2001-04-10 17:51             ` yodaiken
2001-04-11 18:43           ` Oliver Xymoron
2001-04-10 12:11       ` Mark Salisbury
2001-04-10  5:51     ` Andi Kleen
2001-04-10  9:33       ` Martin Mares
2001-04-10 10:00         ` Albert D. Cahalan
2001-04-10 12:14         ` Mark Salisbury
2001-04-11  5:55           ` Karim Yaghmour
2001-04-10 11:18       ` Alan Cox
2001-04-10 12:02         ` Andi Kleen
2001-04-10 12:12           ` Alan Cox
2001-04-10 12:27             ` Mark Salisbury
2001-04-10 12:32             ` Andi Kleen
2001-04-10 12:36               ` Alan Cox
2001-04-10 12:37                 ` Andi Kleen
2001-04-10 18:45               ` Stephen D. Williams
2001-04-10 19:59                 ` Andi Kleen
2001-04-10 12:07       ` Mark Salisbury
2001-04-10 12:45         ` Andi Kleen
2001-04-10 12:42           ` Mark Salisbury
2001-04-10 12:54             ` Andi Kleen

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=3AD72428.CBA4F2B7@mvista.com \
    --to=george@mvista.com \
    --cc=bret@io.com \
    --cc=greearb@candelatech.com \
    --cc=high-res-timers-discourse@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lk@tantalophile.demon.co.uk \
    /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).