you are in an fs with millions of small files

Poul-Henning Kamp phk at phk.freebsd.dk
Thu Jun 9 19:15:57 GMT 2005


In message <200506091911.j59JBGQn096385 at gate.bitblocks.com>, Bakul Shah writes:

>Start with a small array.  When it gets full double it (or
>grow by half if you want to waste less memory).

If I might make an observation...

You do not waste malloc'ed memory until you access it.  You waste some
page table entries etc in the kernel, but the actual pages do not
become part of the memory-pressure mob-rule until you touch it the
first time.

This is a very important point which people still (after 20 years of
virtual memory systems and 10 years of phkmalloc) still do not seem
to have fully understood.

I would advice a simple doubling and a terminal realloc to cut down
to actual size.


-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.


More information about the freebsd-fs mailing list