From: Yannick Gingras <ygingras@ygingras.net>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: git@vger.kernel.org
Subject: Re: On the many files problem
Date: Mon, 31 Dec 2007 05:13:45 -0500 [thread overview]
Message-ID: <873atjtbmu.fsf@enceladus.ygingras.net> (raw)
In-Reply-To: <alpine.LFD.0.9999.0712291055470.2778@woody.linux-foundation.org> (Linus Torvalds's message of "Sat\, 29 Dec 2007 11\:12\:38 -0800 \(PST\)")
Thanks to you and to Junio for your replies,
Linus Torvalds <torvalds@linux-foundation.org> writes:
> No, no. The fastest way to store a bunch of files is to basically:
>
> - make the filenames as small as possible
>
> This improves density, and thus performance. You'll get more files to
> fit in a smaller directory, and filename compares etc will be faster
> too.
>
> If you don't need hashes, but can do with smaller names (for example,
> your names are really just sequential, and you can use some base-64
> encoding to make them smaller than numbers), you'll always be better
> off.
This is really interesting and I would not have suspected it. But it
begs the question: why does Git use the base-16 hash instead of the
base-64 hash?
After your replies I took a serious look at Git's storage and there is
indeed not that many loose objects in a typical repo: most is kept
into packs. So I guess Git doesn't need that much density and keeping
the filename in the format that is used in the UI probably helps power
users.
> - store them in a good final order. This is debatable, but depending on
> your load and the filesystem, it can be better to make sure that you
> create all files in order, because performance can plummet if you start
> removing files later.
>
> I suspect your benchmark *only* tested this case,
That is true.
> but if you want to check odder cases, try creating a huge
> directory, and then deleting most files, and then adding a few
> new ones. Some filesystems will take a huge hit because they'll
> still scan the whole directory, even though it's mostly empty!
>
> (Also, a "readdir() + stat()" loop will often get *much* worse access
> patterns if you've mixed deletions and creations)
This is something that will be interesting to benchmark later on. So,
an application with a lot of turnaround, say a mail server, should
delete and re-create the directories from time to time? I assume this
is specific to some file system types.
> - it's generally *much* more efficient to have one large file that you
> read and seek in than having many small ones, so if you can change your
> load so that you don't have tons of files at all, you'll probably be
> better off.
That makes a lot of sense.
Thanks again for those clarifications.
--
Yannick Gingras
next prev parent reply other threads:[~2007-12-31 10:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-29 18:22 On the many files problem Yannick Gingras
2007-12-29 19:12 ` Linus Torvalds
2007-12-31 10:13 ` Yannick Gingras [this message]
2007-12-31 20:45 ` Linus Torvalds
2007-12-31 23:31 ` Martin Langhoff
2007-12-29 19:27 ` Junio C Hamano
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=873atjtbmu.fsf@enceladus.ygingras.net \
--to=ygingras@ygingras.net \
--cc=git@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 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.