I ran in this problem, hard, and I can vouch that this is not a windows-only
problem. ReiserFS, ext3 and OSX's HFS+ become cripplingly slow with more
than a few hundred thousand files in the same directory. (The operation to
correct this mistake took a week to run.)  That is one of several hard
lessons I learned about "don't write your scraper to replicate the path
structure of each document as a file on disk."

Cascading the directory structure works, but sucks in various other ways,
and itself stops scaling after a while.  What I eventually realized is that
I was using the filesystem as a particularly wrongheaded document database,
and that the metadata delivery of a filesystem just doesn't work for this.

Since in our application the files are text and are immutable, our adhoc
solution is to encode and serialize each file with all its metadata, one per
line, into a flat file.

A distributed database is probably the correct answer, but this is working
quite well for now and even has some advantages. (No-cost replication from
work to home or offline by rsync or thumb drive, for example.)

flip

On Fri, Jan 23, 2009 at 5:49 PM, Raghu Angadi <[email protected]> wrote:

> Mark Kerzner wrote:
>
>> But it would seem then that making a balanced directory tree would not
>> help
>> either - because there would be another binary search, correct? I assume,
>> either way it would be as fast as can be :)
>>
>
> But the cost of memory copies would be much less with a tree (when you add
> and delete files).
>
> Raghu.
>
>
>
>>
>> On Fri, Jan 23, 2009 at 5:08 PM, Raghu Angadi <[email protected]>
>> wrote:
>>
>>  If you are adding and deleting files in the directory, you might notice
>>> CPU
>>> penalty (for many loads, higher CPU on NN is not an issue). This is
>>> mainly
>>> because HDFS does a binary search on files in a directory each time it
>>> inserts a new file.
>>>
>>> If the directory is relatively idle, then there is no penalty.
>>>
>>> Raghu.
>>>
>>>
>>> Mark Kerzner wrote:
>>>
>>>  Hi,
>>>>
>>>> there is a performance penalty in Windows (pardon the expression) if you
>>>> put
>>>> too many files in the same directory. The OS becomes very slow, stops
>>>> seeing
>>>> them, and lies about their status to my Java requests. I do not know if
>>>> this
>>>> is also a problem in Linux, but in HDFS - do I need to balance a
>>>> directory
>>>> tree if I want to store millions of files, or can I put them all in the
>>>> same
>>>> directory?
>>>>
>>>> Thank you,
>>>> Mark
>>>>
>>>>
>>>>
>>
>


-- 
http://www.infochimps.org
Connected Open Free Data

Reply via email to