LWN: Comments on "One billion files on Linux" https://lwn.net/Articles/400629/ This is a special feed containing comments posted to the individual LWN article titled "One billion files on Linux". en-us Wed, 24 Sep 2025 07:14:20 +0000 Wed, 24 Sep 2025 07:14:20 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net hard links ? https://lwn.net/Articles/402647/ https://lwn.net/Articles/402647/ pixelpapst <div class="FormattedComment"> I guess Ric has done the big rm -R already, but for the next experiment, I'd be interested in trying a cp -al. This is something I use a lot, probably more than is strictly healthy. Bonus points for trying to diff -ur the two beasts. :-)<br> </div> Sat, 28 Aug 2010 06:57:16 +0000 One billion files on Linux https://lwn.net/Articles/401598/ https://lwn.net/Articles/401598/ pr1268 <p>One can only imagine you used a script to generate the files and directories. Either that, or you are a very fast typist! ;-)</p> Tue, 24 Aug 2010 01:06:26 +0000 One billion files on Linux https://lwn.net/Articles/401597/ https://lwn.net/Articles/401597/ roelofs <FONT COLOR="#448800"><I>there is an option to tell ls not to bother sorting the output (-N IIRC) and I've found that to be significant in many cases.</I></FONT> <P> I think you mean <TT>-f</TT> (at least for GNU ls). <TT>-N</TT> has something to do with quoting, according to <TT>ls --help</TT>. I've used the former but not the latter, AFAIR. <P> Greg Tue, 24 Aug 2010 00:59:55 +0000 One billion files on Linux https://lwn.net/Articles/401230/ https://lwn.net/Articles/401230/ mhelsley <div class="FormattedComment"> Thanks for the clarification.<br> <p> This use of rsync presents an interesting case for the userspace portion of checkpoint/restart.<br> <p> During checkpoint we often need to checkpoint the contents of the filesystems. One way to do that is with a frozen filesystem and rsync. Obviously if we're rsync'ing to mirror the filesystem in the first place then we shouldn't attempt to checkpoint the rsync task's filesystem(s) with rsync -- we'd want to do a "local" snapshot if possible.<br> <p> Since the kernel does not force userspace to save the filesystem contents userspace can choose if and how it will do so. In other words this case requires no special changes to the checkpoint syscall.<br> </div> Fri, 20 Aug 2010 21:54:57 +0000 One billion files on Linux https://lwn.net/Articles/401163/ https://lwn.net/Articles/401163/ ricwheeler <div class="FormattedComment"> My general point was that anything that takes days or weeks to complete, will break eventually. Think of using rsync to mirror a billion files over a wide area network for example. After a network issue or a power outage, you do not want to have to start from the first file.<br> <p> How you checkpoint/restart is less critical to me. I would see that some applications (like rsync itself) should be aware and restartable in their design. Others would certainly benefit from external checkpointing.<br> <p> </div> Fri, 20 Aug 2010 18:12:31 +0000 One billion files on Linux https://lwn.net/Articles/401033/ https://lwn.net/Articles/401033/ dlang <div class="FormattedComment"> one of the headaches with doing a ls on a large number of files is that by default ls fetches everything then sorts it all by filename. there is an option to tell ls not to bother sorting the output (-N IIRC) and I've found that to be significant in many cases.<br> </div> Fri, 20 Aug 2010 00:08:33 +0000 One billion files on Linux https://lwn.net/Articles/400988/ https://lwn.net/Articles/400988/ mhelsley <div class="FormattedComment"> "Finally, application developers must bear in mind that processes which run this long will invariably experience failures, sooner or later. So they will need to be designed with some sort of checkpoint and restart capability."<br> <p> Was that exactly Ric's point -- that the applications had to checkpoint themselves? Or did he just say that being able to checkpoint applications was necessary? I ask because there's a big difference. Expecting all applications that might be run in these environments to explicitly checkpoint themselves just isn't practical. Look at how many non-HPC applications use BLCR for example.<br> <p> The alternative is to enable "external" checkpointing. Checkpoints that don't require rewriting the application, or ld preloads, etc. There is already an effort underway to push this to mainline:<br> <p> <a href="https://ckpt.wiki.kernel.org/index.php/Main_Page">https://ckpt.wiki.kernel.org/index.php/Main_Page</a><br> </div> Thu, 19 Aug 2010 20:32:31 +0000 One billion files on Linux https://lwn.net/Articles/400989/ https://lwn.net/Articles/400989/ ricwheeler <div class="FormattedComment"> <p> One thing you can do (and upstream, tools like rm do this now) is to get a bunch of entries back from readdir and then sort them by inode number.<br> <p> That removes the random, seeky nature of the list for file systems that suffer from this (ext3/4, reiserfs, other?).<br> <p> For the more advanced layouts, you should look to btrfs.<br> <p> </div> Thu, 19 Aug 2010 20:16:03 +0000 One billion files on Linux https://lwn.net/Articles/400968/ https://lwn.net/Articles/400968/ liljencrantz <div class="FormattedComment"> The advantage of putting all files in the same directory is that it's slightly easier to code it that way. The disadvantage is that you have directories that effectively can't have their content listed using ls, you likely can't even count the number of files in the directory. Basically some kind of storage tar pit. I think I'll stick to using subfolders. And once mailing lists with more than say 10 million messages in them become common, I'll start worrying about a subfoldered replacement for maildir. :-)<br> <p> </div> Thu, 19 Aug 2010 18:34:45 +0000 One billion files on Linux https://lwn.net/Articles/400967/ https://lwn.net/Articles/400967/ liljencrantz <div class="FormattedComment"> Oh, ok. That makes more sense to me. Thanks for explaining.<br> </div> Thu, 19 Aug 2010 18:27:21 +0000 One billion files on Linux https://lwn.net/Articles/400957/ https://lwn.net/Articles/400957/ bcopeland <p><i>When trying to look at that many files, you need to avoid running stat() on every one of them or trying to sort the whole list.</i></p> <p> Underlying this issue is that today's directories (for ext4 at least) are not set up to iterate in inode order. The consequence is that if you do a walk of the files in the order they are stored in the directory, and the inodes aren't in the cache, you have to seek all over the disk to get to the inode information. I remember reading once that the htree designers planned at some point to group the files in htree leaves into buckets based on inode; I wonder if anything ever came of that?</p> Thu, 19 Aug 2010 17:08:37 +0000 One billion files on Linux https://lwn.net/Articles/400893/ https://lwn.net/Articles/400893/ zzxtty <div class="FormattedComment"> If people are wondering about the validity of 1 billion files I can give an example, I work with MRI data. We do a lot of fMRI which generates lots of files (DICOM images). One file is generated per slice, with fMRI you continuously scan someone for an extended period of time, a single scan can generated 20,000 files. If you've got several MRI scanners and have been up and running for a few years the 1 billion file mark is not large, So far this year we have generated over 23 million files on one of our scanners.<br> <p> However, I'm not sure I'd want to store them all on one file system, it would be a nightmare to restore from tape if anything did go horribly wrong. This is where data management comes in, I create a new partition for each scanner, each year. Currently we run all this on midrange hardware raid and format with zfs, it appears to cope. Would be nice to move it all to Linux =)<br> </div> Thu, 19 Aug 2010 15:20:42 +0000 One billion files on Linux https://lwn.net/Articles/400937/ https://lwn.net/Articles/400937/ ricwheeler <div class="FormattedComment"> <p> The test was for a file system, not for a single directory. In the test I ran, I did use a thousand subdirectories (each with 1 million files).<br> <p> </div> Thu, 19 Aug 2010 15:19:07 +0000 One billion files on Linux https://lwn.net/Articles/400879/ https://lwn.net/Articles/400879/ cesarb <div class="FormattedComment"> <font class="QuotedText">&gt; But in what situations will it make more sense to not group a billion of file items into logical groups?</font><br> <p> Things like squid cache directories, git object directories, ccache cache directories, that hidden thumbnails directory in your $HOME... They all have in common that the files are named by a hash or something similar. There is no logical grouping at all here; it is a completely flat namespace.<br> <p> Most of these work around the large number of files in a single directory this causes by extracting some bits (usually 4 or 8) of the hash and using it as the name of a subdirectory (which works because the hashes used have an almost perfect uniform distribution). Sometimes more than one level is used. If the filesystem can easily deal with a huge number of files in a single directory, this extra complexity is not needed.<br> <p> There is also Maildir directories, which use one file per message, and the only logical grouping is a "folder" or similar. If you have a million messages in a single "folder" (for instance one named "linux-kernel-mailing-list" which has all the messages you collected since 1999), you need a filesystem which can deal with a million files in a single directory. And here the names are not hashes, so the scheme above fails (and even if it worked, it is not a Maildir anymore).<br> </div> Thu, 19 Aug 2010 10:57:02 +0000 One billion files on Linux https://lwn.net/Articles/400870/ https://lwn.net/Articles/400870/ liljencrantz <div class="FormattedComment"> I probably simply lack the imagination, but I fail to see when it would be beneficial to keep as much as a billion files in the same directory. A billion files spread out through a million different directories in a hierarchy? That makes loads of sense, and it's really just a matter of time before that becomes normal enough. But in what situations will it make more sense to not group a billion of file items into logical groups?<br> </div> Thu, 19 Aug 2010 10:13:21 +0000 One billion files on Linux https://lwn.net/Articles/400852/ https://lwn.net/Articles/400852/ niner <div class="FormattedComment"> Recently I did similiar tests for determining how well PostgreSQL would be able to deal with databases with potentially hundreds of thousands of tables. From what I found out, it's only limited by the file system's ability to work with that many files in a single directory.<br> <p> So I tried that and put about 4.3 millions of files in a directory on my ext4 file system. Took quite a while to create and delete later on but file access times where impressive. It seems like accessing a file by it's name in such a directory takes a pretty much constant amount of time. Reading in the directory is quite fast as well, though that obviously takes longer the larger the directory is.<br> </div> Thu, 19 Aug 2010 06:54:14 +0000