From: Simon Lodal <simonl@parknet.dk>
To: Andi Kleen <ak@suse.de>
Cc: Patrick McHardy <kaber@trash.net>,
netdev@vger.kernel.org, lartc@mailman.ds9a.nl
Subject: Re: [PATCH] HTB O(1) class lookup
Date: Mon, 5 Feb 2007 19:21:19 +0100 [thread overview]
Message-ID: <200702051921.20146.simonl@parknet.dk> (raw)
In-Reply-To: <p73r6tanmhk.fsf@bingen.suse.de>
On Thursday 01 February 2007 12:30, Andi Kleen wrote:
> Simon Lodal <simonl@parknet.dk> writes:
> > Memory is generally not an issue, but CPU is, and you can not beat the
> > CPU efficiency of plain array lookup (always faster, and constant time).
>
> Actually that's not true when the array doesn't fit in cache.
>
> The cost of going out to memory over caches is so large (factor 100 and
> more) that often algorithms with smaller cache footprint can easily beat
> algorithms that execute much less instructions if it has less cache misses.
> That is because not all instructions have the same cost; anything
> in core is very fast but going out to memory is very slow.
>
> That said I think I agree with your analysis that a two level
> array is probably the right data structure for this and likely
> not less cache efficient than the hash table.
Good point.
The 2-level lookup generates 3 memory accesses (including getting at the
htb_class struct). List traversal will generate many more memory accesses,
unless the lists have 3 or fewer entries (currently that only holds true for
up to 48 classes, uniformly distributed).
It is difficult to judge if the tables will be in cache or not. The tables are
clearly extra baggage for the cachelines, compared to only having the
htb_class structs (they are going to be fetched anyway).
On the other hand, if you have 10k classes, they are usually (real world)
allocated for individual users, of which at most half are active at any time.
With hashing, all 10k classes are fetched into cachelines all the time, only
in order to traverse lists. That is >150k wasted cache (5000 x 32 bytes);
plenty for 10k pointers in lookup tables.
Regards
Simon
next prev parent reply other threads:[~2007-02-05 18:22 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-01 5:18 [PATCH] HTB O(1) class lookup Simon Lodal
2007-02-01 6:08 ` Patrick McHardy
2007-02-01 7:08 ` Simon Lodal
2007-02-01 11:30 ` Andi Kleen
2007-02-05 10:16 ` Jarek Poplawski
2007-02-05 11:24 ` Andi Kleen
2007-02-05 12:45 ` Ingo Oeser
2007-02-05 17:14 ` Simon Lodal
2007-02-06 8:08 ` Jarek Poplawski
2007-02-08 7:36 ` Jarek Poplawski
2007-02-05 18:21 ` Simon Lodal [this message]
2007-02-01 13:06 ` jamal
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=200702051921.20146.simonl@parknet.dk \
--to=simonl@parknet.dk \
--cc=ak@suse.de \
--cc=kaber@trash.net \
--cc=lartc@mailman.ds9a.nl \
--cc=netdev@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 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).