mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Trond Myklebust <trondmy@hammerspace.com>
To: "torvalds@linux-foundation.org" <torvalds@linux-foundation.org>
Cc: "linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [GIT PULL] Please pull NFS client changes for Linux 5.18
Date: Wed, 30 Mar 2022 20:01:47 +0000	[thread overview]
Message-ID: <c5401981cb21674bdd3ffd9cc4fac9fe48fb8265.camel@hammerspace.com> (raw)
In-Reply-To: <CAHk-=wh-hs_q-sL6PNptfVmNm7tWrt24o4-YR74Fxo+fdKsmxA@mail.gmail.com>

On Wed, 2022-03-30 at 11:17 -0700, Linus Torvalds wrote:
> On Tue, Mar 29, 2022 at 12:36 PM Trond Myklebust
> <trondmy@hammerspace.com> wrote:
> > 
> > - Readdir fixes to improve cacheability of large directories when
> > there
> >   are multiple readers and writers.
> 
> So I only took a look at this part now. I've obviously already pulled
> it, but that use of 'xxhash()' just made me go "Whaaa?"
> 
> It's claimed that it's used because of its extreme performance, but
> the performance numbers come from using it as a block hash.
> 
> That's not what nfs does.
> 
> The nfs code just does
> 
>     xxhash(&cookie, sizeof(cookie), 0) & NFS_READDIR_COOKIE_MASK;
> 
> where that "cookie" is just a 64-bit entity. And then it masks off
> everything but 18 bits.
> 
> Is that *really* appropriate use of a new hash function?
> 
> Why is this not just doing
> 
>   #include <hash.h>
> 
>   hash_64(cookie, 18);
> 
> which is a lot more obvious than xxhash().
> 
> If there really are some serious problems with the perfectly standard
> hash() functionality, I think you should document them.
> 
> Because just randomly picking xxhash() without explaining _why_ you
> can't just use the same simple thing we use elsewhere is very odd.
> 
> Or rather, when the only documentation is "performance", then I think
> the regular "hash_64()" is the obvious and trivial choice.
> 
>                   Linus

My main worry was that hash_64() would have too many collisions. Since
this is using cuckoo nesting, that would be a problem.

I did some quick studies after I got your email, and it seems as if my
concerns were unfounded. I've tested both a linear index and a sample
of ext4 getdents offsets.
While the sample of ext4 offsets did show a larger number of collisions
than a simple linear index, it wasn't too terrible (3 collisions in a
sample of 9000 entries).
The linear index showed no collisions up to about 100000 entries.

So, I'd be OK with changing to hash_64() and will queue up a bugfix for
it. I should have done this study earlier...

-- 
Trond Myklebust
Linux NFS client maintainer, Hammerspace
trond.myklebust@hammerspace.com



  reply	other threads:[~2022-03-30 20:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-29 19:36 Trond Myklebust
2022-03-30  2:00 ` pr-tracker-bot
2022-03-30 18:17 ` Linus Torvalds
2022-03-30 20:01   ` Trond Myklebust [this message]
2022-03-30 20:11     ` Linus Torvalds
2022-03-30 22:22     ` Trond Myklebust
2022-03-30 22:45       ` Linus Torvalds
2022-03-30 23:18         ` Trond Myklebust
2022-03-31  0:52           ` Linus Torvalds

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=c5401981cb21674bdd3ffd9cc4fac9fe48fb8265.camel@hammerspace.com \
    --to=trondmy@hammerspace.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=torvalds@linux-foundation.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

all inboxes | Powered by JetHome®