Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 7 Oct 2001 18:54:08 +0200
From:      Erik Trulsson <ertr1013@student.uu.se>
To:        Charles Burns <burnscharlesn@hotmail.com>
Cc:        mpd6334@cs.rit.edu, questions@freebsd.org
Subject:   Re: Maximum Freebsd Directory entries?
Message-ID:  <20011007185408.A11131@student.uu.se>
In-Reply-To: <F219rOzV5j5P6Q3Ty4J00013c1c@hotmail.com>
References:  <F219rOzV5j5P6Q3Ty4J00013c1c@hotmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Oct 07, 2001 at 09:38:03AM -0700, Charles Burns wrote:
> 
> >On Fri, Oct 05, 2001 at 11:06:18AM -0700, Dreamtime.net Inc. wrote:
> >> How many directories could be created in a directory under freebsd 3.2. 
> >If
> >> there is some limitation, is it possible to work
> >> around it?
> >
> >if there is a set limit, why would you want to raise it?
> >access becomes RIDICULOUSLY slow when there are thousands
> >of files in a directory.
> 
> Is file access slow in directories containing many entries, or were you 
> referring to listing the contents only? If the former, is it them better to 
> minimize the # of entries (not going to any special effort, but in 
> general...) in a certain directory?
> 

Accessing files in a directory with many entries is slow. This is
because a linear search is used to find a file within a directory. The
time to access a file is therefore proportional to the number of
entries in the directory.

This does not mean that one should go to great length to minimize the
number of entries in a directory since there is not much difference
between 10 or 20 or 100 entries.

I would say that the practical limit for how many entries on can have
in a single directory without things getting too slow is somewhere
around 3000.  ( Directories usually becomes fairly unwieldy for humans
at a couple of hundred files so I would say that anything above, say,
500 entries in a single directory should be avoided unless one has a
specific reason for putting that many files in one directory.)


It can also be worth noting that there are some (experimental) code in
the kernel to speed up access in large directories by using a hashtable
but this is not enabled by default. (options UFS_DIRHASH in the kernel
config file).



-- 
<Insert your favourite quote here.>
Erik Trulsson
ertr1013@student.uu.se


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011007185408.A11131>