Jump to content

file system performance; how many files in one dir


Go to solution Solved by requinix,

Recommended Posts

I understand structure for human needs but does a unix file system need it?

 

I'm accumulating a lot of image files.  After I  mangle the file name, the raw image files are being dumped in a single directory while all the image file's meta data is being stored in a database.  Does a unix file system prefer structure, lots of little directories, or does it deal just fine with many files in one.

 

All 'find that file' processes begin with the database.

 

 

Thank you.

  • Solution

Depends on the filesystem. ext4 (most common?) doesn't have a limit per directory. However directories themselves take space to store a list of their contents, and unless the system sorts directory entries (?) looking for a file requires scanning the directory list for it.

 

It might be antiquated now but if you know the filename from another source then I'd partition. I tend to generate hex filenames and take the first two bytes' worth as two subdirectories.

/01/23/0123456789abcdef.ext
Assuming an even distribution, by the time you've filled each second-level directory with 256 files you've stored 16M total. More than enough.

I was thinking about hashes and cache at the time and thinking size made NO difference.  But, then, I don't know.  And in the end size does always seem to matter.  Your method looks like a good way to 'distribute'.  I'll use it.  Looking at a directory with so many files has me on edge... like something is going to blow.  Thanks for tip.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.