From: Josef Bacik <jbacik@fb.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andi Kleen <andi@firstfloor.org>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
Al Viro <viro@zeniv.linux.org.uk>,
Christoph Hellwig <hch@infradead.org>, Chris Mason <clm@fb.com>
Subject: Re: Name hashing function causing a perf regression
Date: Fri, 12 Sep 2014 17:25:50 -0400 [thread overview]
Message-ID: <541364DE.5030104@fb.com> (raw)
In-Reply-To: <CA+55aFw52k0wKkVP85G+x_OoQwyfvP5yFEguHn8E4qd4gLOUiw@mail.gmail.com>
On 09/12/2014 04:39 PM, Linus Torvalds wrote:
> On Fri, Sep 12, 2014 at 12:52 PM, Josef Bacik <jbacik@fb.com> wrote:
>>
>> So that looks much better, not perfect but hlist_for_each through 5 entries
>> isn't going to kill us, I'll build a kernel with this and get back shortly
>> with real numbers.
>
> So one thing to look out for is that the fold_hash() is only effective
> for 64-bit architectures, and I'm pretty sure that we end up having a
> very similar issue on 32-bit architectures that have
>
> - two 32-bit words with the fairly simplisting mixing (basically
> "first word * 9 + second word")
>
> This is probably ok'ish, in that you end up still having a 32-bit
> number with *most* of the bits being relevant, but we should think
> about this too.
>
> - the real problem is likely the "d_hash()" function that narrows the
> 32-bit hash down to d_hash_mask bits, and drops a lot of bits as it
> does so (ie d_hash_mask is usually on the order of 12 bits, so it
> really only uses 24 bits of the 32-bit hash value, and 12 bits is
> particularly bad anyway, since it's a multiple of three which is what
> the '9' in the first simplistic mixing used too.
>
> So it *might* be better to fix this all at d_hash() instead, and make
> that use "hash_u32(hash, d_hash_bits)" instead. And maybe keep the
> fold_hash() stage fairly stupid.
>
> Anyway, what I'm trying to say is that your numbers are certainly
> *much* better than the hash bucket list used to be, but we should
> probably tweak it a bit more. I'm not sure you really need to go to a
> real hash function like murmur, but it would also be a good idea to at
> least look at making some initial value be randomized so that people
> also can't quite as easily perhaps try to hit worst-case situations
> where they control the hash and can make really long buckets (the fact
> that we mix in the parent pointer and many filesystems have some
> directory size limit might make that harder anyway, but..)
>
Ok I have a good direction to take this in, so far the best results have
been to change fold_hash() to hash_64(hash, 32) and change d_hash to do this
static int *d_hash(int *table, unsigned long parent, unsigned int hash)
{
hash += (unsigned long) parent / L1_CACHE_BYTES;
hash += hash_32(hash, d_hash_shift);
return table + (hash & d_hash_mask);
}
which has gotten us 890k buckets. I'll futz with it some more on Monday
and send out a patch with whatever gives me the best numbers. Thanks
for the help, hashing is not my forte,
Josef
next prev parent reply other threads:[~2014-09-12 21:26 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-09 19:30 Name hashing function causing a perf regression Josef Bacik
2014-09-12 19:11 ` Andi Kleen
2014-09-12 19:21 ` Linus Torvalds
2014-09-12 19:52 ` Josef Bacik
2014-09-12 20:39 ` Linus Torvalds
2014-09-12 21:25 ` Josef Bacik [this message]
2014-09-12 22:01 ` Linus Torvalds
2014-09-12 22:08 ` Josef Bacik
2014-09-12 22:25 ` Linus Torvalds
2014-09-13 18:58 ` Linus Torvalds
2014-09-15 1:32 ` Linus Torvalds
2014-09-15 2:49 ` Tetsuo Handa
2014-09-15 3:37 ` Linus Torvalds
2014-09-15 4:58 ` Tetsuo Handa
2014-09-15 14:17 ` Linus Torvalds
2014-09-15 15:55 ` Josef Bacik
2014-09-15 16:22 ` Linus Torvalds
2014-09-15 16:25 ` Al Viro
2014-09-15 16:33 ` Linus Torvalds
2014-09-15 16:35 ` Greg KH
2014-09-15 16:45 ` Linus Torvalds
2014-09-15 16:53 ` Jiri Slaby
2014-09-15 17:31 ` Greg KH
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=541364DE.5030104@fb.com \
--to=jbacik@fb.com \
--cc=andi@firstfloor.org \
--cc=clm@fb.com \
--cc=hch@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--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 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.