Re: [RFC PATCH] index-pack: improve performance on NFS
- Date: Mon, 29 Oct 2018 22:21:19 +0000
- From: Geert Jansen <gerardu@xxxxxxxxxx>
- Subject: Re: [RFC PATCH] index-pack: improve performance on NFS
On Mon, Oct 29, 2018 at 05:50:50PM -0400, Jeff King wrote:
> > I believe the loose-object-cache approach would have a performance regression
> > when you're receiving a small pack file and there's many loose objects in the
> > repo. Basically you're trading off
> > MIN(256, num_objects_in_pack / dentries_per_readdir) * readdir_latency
> > against
> > num_loose_objects * stat_latency
> Should num_loose_objects and num_objects_in_pack be swapped here? Just
> making sure I understand what you're saying.
Whoops, yes, thanks for spotting that!
> So the 256 in your MIN() is potentially much smaller. We still have to
> deal with the fact that if you have a large number of loose objects,
> they may be split cross multiple readdir (or getdents) calls. The "cache
> maximum" we discussed does bound that, but in some ways that's worse:
> you waste time doing the bounded amount of readdir and then don't even
> get the benefit of the cache. ;)
Yup. To get the performance benefit you'd like the cache to hold all loose
objects except in clearly degenerate cases with far too many loose objects.
> > On Amazon EFS (and I expect on other NFS server implementations too) it is more
> > efficient to do readdir() on a large directory than to stat() each of the
> > individual files in the same directory. I don't have exact numbers but based on
> > a very rough calculation the difference is roughly 10x for large directories
> > under normal circumstances.
> I'd expect readdir() to be much faster than stat() in general (e.g., "ls
> -f" versus "ls -l" is faster even on a warm cache; there's more
> formatting going on in the latter, but I think a lot of it is the effort
> to stat).
In the case of NFS, the client usually requests that the READDIR response also
contains some of the stat flags (like st_mode). But even in this case it's
still more efficient to return multiple entries in one batch through READDIR
rather than as individual responses to GETATTR (which is what stat() maps to).