From: Willy Tarreau <willy@w.ods.org>
To: linux-kernel@vger.kernel.org
Subject: Re: Route cache performance under stress
Date: Sat, 5 Apr 2003 20:34:18 +0200 [thread overview]
Message-ID: <20030405183418.GA554@alpha.home.local> (raw)
In-Reply-To: <8765pshpd4.fsf@deneb.enyo.de>
Hello !
On Sat, Apr 05, 2003 at 06:37:43PM +0200, Florian Weimer wrote:
> Please read the following paper:
>
> <http://www.cs.rice.edu/~scrosby/tr/HashAttack.pdf>
very interesting article.
> Then look at the 2.4 route cache implementation.
Since we need commutative source/dest addresses in many places, the use of a
XOR is a common practice. In fact, while working on hash tables a while ago, I
found that I could get very good results with something such as :
RND1 = random_generated_at_start_time() ;
RND2 = random_generated_at_start_time() ;
/* RND2 may be 0 or equal to RND1, all cases seem OK */
x = (RND1 - saddr) ^ (RND1 - daddr) ^ (RND2 + saddr + daddr);
reduce(x) ...
With this method, I found no way to guess a predictable (saddr, daddr) couple
which gives a same result, and saddr/daddr are still commutative. It resists
common cases where saddr=daddr, saddr=~daddr, saddr=-daddr. And *I think* tha
the random makes other cases difficult to predict. I'm not specialized in
crypto or whatever, so I cannot tell how to generate the best RND1/2, and it's
obvious to me that stupid values like 0 or -1 may not help a lot, but this is
still better than a trivial saddr ^ daddr, at a very low cost.
For example, the x86 encoding of the simple XOR hash would result in :
mov saddr, %eax
xor daddr, %eax
=> 2 cycles with result in %eax
The new calculation will look like :
mov saddr, %ebx
mov daddr, %ecx
lea (%ebx,%ecx,1), %eax
neg %ecx
add RND2, %eax // can be omitted if zero
add RND1, %ecx
neg %ebx
xor %ecx, %eax
add RND1, %ebx
xor %ebx, %eax
=> 5 cycles on dual-pipelines CPUs, result in eax, but uses 2 more regs.
Any comments ?
Regards,
Willy
next prev parent reply other threads:[~2003-04-05 18:22 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-04-05 16:37 Route cache performance under stress Florian Weimer
2003-04-05 18:17 ` Martin Josefsson
2003-04-05 18:34 ` Willy Tarreau [this message]
2003-05-16 22:24 ` Simon Kirby
2003-05-16 23:16 ` Florian Weimer
2003-05-19 19:10 ` Simon Kirby
2003-05-17 2:35 ` David S. Miller
2003-05-17 7:31 ` Florian Weimer
2003-05-17 22:09 ` David S. Miller
2003-05-18 9:21 ` Florian Weimer
2003-05-18 9:31 ` David S. Miller
2003-05-19 17:36 ` Jamal Hadi
2003-05-19 19:18 ` Ralph Doncaster
-- strict thread matches above, loose matches on Subject: below --
2003-04-08 6:14 Scott A Crosby
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=20030405183418.GA554@alpha.home.local \
--to=willy@w.ods.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox