From: Stephen Hemminger <shemminger@vyatta.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Eric Dumazet <eric.dumazet@gmail.com>,
Stephen Hemminger <stephen.hemminger@vyatta.com>,
Andrew Morton <akpm@linux-foundation.org>,
Octavian Purdila <opurdila@ixiacom.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: [PATCH] dcache: better name hash function
Date: Tue, 27 Oct 2009 18:56:13 -0700 [thread overview]
Message-ID: <20091027185613.1a7e8398@nehalam> (raw)
In-Reply-To: <alpine.LFD.2.01.0910271744560.31845@localhost.localdomain>
On Tue, 27 Oct 2009 17:58:53 -0700 (PDT)
Linus Torvalds <torvalds@linux-foundation.org> wrote:
>
>
> On Tue, 27 Oct 2009, Stephen Hemminger wrote:
> >
> > Agreed. Here is the reduced version of the program.
> > To run:
> > find /home -printf '%f\n' 2>/dev/null | ./htest -n 100
>
> The timings are very sensitive to random I$ layout at least on Nehalem.
> The reason seems to be that the inner loop is _so_ tight that just
> depending on exactly where the loop ends up, you can get subtle
> interactions with the loop cache.
>
> Look here:
>
> [torvalds@nehalem ~]$ find /home -printf '%f\n' 2>/dev/null | ./htest -n 100
> Algorithm Time Ratio Max StdDev
> full_name_hash 1.141899 1.03 4868 263.37
> djb2 0.980200 1.03 4835 266.05
> string10 0.909175 1.03 4850 262.67
> string10a 0.673915 1.03 4850 262.67
> string10b 0.909374 1.03 4850 262.67
> string_hash17 0.966050 1.03 4805 263.68
> string_hash31 1.008544 1.03 4807 259.37
> fnv32 0.774806 1.03 4817 259.17
>
> what do you think the difference between 'string10', 'string10a' and
> 'string10b' are?
>
> None. None what-so-ever. The source code is identical, and gcc generates
> identical assembly language. Yet those timings are extremely stable for
> me, and 'string10b' is 25% faster than the identical string10 and
> string10a functions.
>
> The only difference? 'string10a' starts aligned to just 16 bytes, but that
> in turn happens to mean that the tight inner loop ends up aligned on a
> 128-byte boundary. And being cacheline aligned just there seems to matters
> for some subtle micro-architectural reason.
>
> The reason I noticed this is that I wondered what small modifications to
> 'string10' would do for performance, and noticed that even _without_ the
> small modifications, performance fluctuated.
>
> Lesson? Microbenchmarks like this can be dangerous and misleading. That's
> _especially_ true if the loop ends up being just tight enough that it can
> fit in some trace cache or similar. In real life, the name hash is
> performance-critical, but at the same time almost certainly won't be run
> in a tight enough loop that you'd ever notice things like that.
>
> Linus
Thanks. I wasn't putting huge amount of stock in the micro benchmark,
was more interested in how the distribution worked out (which is CPU
independent) rather than the time. As long as all usage of name hashing
fold properly, there isn't a lot of reason to change.
--
next prev parent reply other threads:[~2009-10-28 1:56 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <9986527.24561256620662709.JavaMail.root@tahiti.vyatta.com>
2009-10-27 5:19 ` [PATCH] dcache: better name hash function Stephen Hemminger
2009-10-27 5:24 ` David Miller
2009-10-27 17:22 ` [PATCH] net: fold network name hash Stephen Hemminger
2009-10-27 18:02 ` Octavian Purdila
2009-10-27 22:04 ` [PATCH] net: fold network name hash (v2) Stephen Hemminger
2009-10-28 6:07 ` Eric Dumazet
2009-10-28 9:28 ` David Miller
2009-10-28 15:57 ` Stephen Hemminger
2009-10-27 6:07 ` [PATCH] dcache: better name hash function Eric Dumazet
2009-10-27 6:50 ` Eric Dumazet
2009-10-27 7:29 ` Eric Dumazet
2009-10-27 17:07 ` Stephen Hemminger
2009-10-27 17:32 ` Linus Torvalds
2009-10-27 23:08 ` Stephen Hemminger
2009-10-27 23:41 ` Linus Torvalds
2009-10-28 0:10 ` Stephen Hemminger
2009-10-28 0:58 ` Linus Torvalds
2009-10-28 1:56 ` Stephen Hemminger [this message]
[not found] ` <4AE72B91.7040700@gmail.com>
2009-10-27 17:35 ` Stephen Hemminger
2009-10-25 19:58 [PATCH next-next-2.6] netdev: better dev_name_hash Octavian Purdila
2009-10-26 4:43 ` Stephen Hemminger
2009-10-26 22:36 ` [PATCH] dcache: better name hash function Stephen Hemminger <shemminger@vyatta.com>, Al Viro
2009-10-27 2:45 ` Eric Dumazet
2009-10-27 3:53 ` Stephen Hemminger
2009-10-27 16:38 ` Rick Jones
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=20091027185613.1a7e8398@nehalam \
--to=shemminger@vyatta.com \
--cc=akpm@linux-foundation.org \
--cc=eric.dumazet@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=opurdila@ixiacom.com \
--cc=stephen.hemminger@vyatta.com \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.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).