git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: On the many files problem

From
Martin Langhoff <martin.langhoff@gmail.com>
Date
Dec 31, 2007, 23:31 UTC
Message-ID
<46a038f90712311531x17b6d94aua1bac2d3d186f186@mail.gmail.com>
In-Reply-To
<873atjtbmu.fsf@enceladus.ygingras.net>
On Dec 31, 2007 11:13 PM, Yannick Gingras <ygingras@ygingras.net> wrote:
Show 12 quoted lines
> >    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.

This is indeed the case. Directories with a lot of movement get fragmented on most FSs -- ext3 is a very bad case for this -- and there are no "directory defrag" tools other than regenarating them. The "Maildir" storage used for many IMAP servers these days shows the problem.

This (longish) threads has some interesting tidbits on getdents() and directory fragmentation. http://kerneltrap.org/mailarchive/git/2007/1/7/235215

cheers,
m
Previous: Linus TorvaldsNext: Junio C Hamano
Message 5 of 6 in “On the many files problem”
  1. Yannick GingrasDec 29, 2007
  2. Linus TorvaldsDec 29, 2007
  3. Yannick GingrasDec 31, 2007
  4. Linus TorvaldsDec 31, 2007
  5. Martin LanghoffDec 31, 2007
  6. Junio C HamanoDec 29, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.