All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matti Aarnio <matti.aarnio@zmailer.org>
To: James Lamanna <jlamanna@ugcs.caltech.edu>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [OT] use of patented algorithms in the kernel ok or not?
Date: Mon, 22 Dec 2003 13:32:58 +0200	[thread overview]
Message-ID: <20031222113258.GM1343@mea-ext.zmailer.org> (raw)
In-Reply-To: <opr0j63dxpz4tciz@192.168.1.1>

On Sun, Dec 21, 2003 at 05:43:51PM -0800, James Lamanna wrote:
> On Sun, 21 Dec 2003 14:40:40 -0500 Lennert Buytenhek wrote:
> >There is one already, and it's suboptimal, to say it mildly.
> 
> What algorithm does the kernel currently use for prefix-matching? I'm 
> interested now...
> And when you say suboptimal, what kind of difference are we talking?
> O(n) vs. O(1) lookups?

(I am reading 2.6.0 kernel source)

It used to be PATRICIA -- where you have binary-searchable sub-tables,
and you look from longest mask table first to see matches. If longer
mask table does not have a match, you move up to larger entries entries.

Now things are somewhat different, and murky underneath FIB-rules.
( net/ipv4/fib_*.c )   The lowest level has fib_hash.c doing lookups
thru  fn_hash_lookup()  function.

It does use hashes, which can, perhaps, do things in speedier, if not
all that cache friendly way.   Still, when you have multiple different
size prefixes, they are all processed the same way as PATRICIA does.

Original question was aiming to run with _full_ internet routing tables
in Linux kernel.  Now _that_ can be somewhat slow, and the patented
algorithm in question is able to handle it under 12 memory lookups in
all cases, while present hash-patricia chunks away a lot more time in
pessimal case.

In normal single interface IPv4 end-node usage we have 4 route entries.
(eth0, loopback, multicast, and default -routes.)  Those should be very
quick to go thru in linear search order and be processor cache friendly.

Even with a handfull of routes (and interfaces), but relying on default-
route to handle most things, I do claim that linear (ordered by mask
specifity!) search table is fastest.(*)

*) It depends on your machine hardware details, but CPU and its associated
   caches are these days factor 100 faster, than main memory random access.
   (And the gap is growing...)

> James Lamanna

/Matti Aarnio

  reply	other threads:[~2003-12-22 11:33 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-22  1:43 [OT] use of patented algorithms in the kernel ok or not? James Lamanna
2003-12-22 11:32 ` Matti Aarnio [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-12-21  1:12 Albert Cahalan
2003-12-21 10:53 ` Jamie Lokier
2003-12-21 13:35   ` James Morris
2003-12-21 14:30     ` Jamie Lokier
2003-12-21 16:03       ` Xavier Bestel
2003-12-21 14:56     ` Arjan van de Ven
2003-12-21 19:33       ` Stan Bubrouski
2003-12-21 23:25         ` Helge Hafting
2003-12-21 19:29   ` Stan Bubrouski
2003-12-21 19:55     ` Matthias Schniedermeyer
2003-12-21 20:11       ` Stan Bubrouski
2003-12-21 21:52       ` Francois Romieu
2003-12-21 21:57     ` Jamie Lokier
2003-12-22  9:50       ` John Bradford
2003-12-22 15:34         ` Adrian Cox
2003-12-18 23:11 Lennert Buytenhek
2003-12-19  6:10 ` Linus Torvalds
2003-12-19  7:38 ` Paul Jackson
2003-12-19  8:47 ` Arjan van de Ven
2003-12-19 11:38   ` Jan-Benedict Glaw
2003-12-20 17:28   ` Stefan Traby
2003-12-21 10:33   ` Jamie Lokier
2003-12-21 16:57     ` Pavel Machek
2004-01-13 15:35       ` Chuck Campbell
2004-01-13 19:35         ` Pavel Machek
2004-01-13 21:04           ` Richard B. Johnson
2003-12-22  0:37     ` jw schultz
2003-12-21 23:39   ` Lennert Buytenhek
2003-12-21  1:25 ` jw schultz
2003-12-21 19:40   ` Lennert Buytenhek

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=20031222113258.GM1343@mea-ext.zmailer.org \
    --to=matti.aarnio@zmailer.org \
    --cc=jlamanna@ugcs.caltech.edu \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.