5/27 How heavily cached is the file system? If I read a file over and over
again, how much (in terms of mb) is it usually in memory, in systems
like FreeBSD?
\_ Your hard drive has a cache as well.
\_ Note that this matters less and less as you get a big software
cache -- in the worst case, if your hardware and software caches
were the same size and used the same policy, you wouldn't get
any benefit from the hardware cache at all.
\_ You fail to mention hard drives that prefetch into their
cache.
This is pretty much unrelated to the original question, whose
answer is "usually most of it; run top to see how much of your
physical memory is allocated to cache".
\_ If the file you're reading over and over again is a read-only
file, or changes in small incremental, it may be wise to use a
database who's sole task is "smart disk cache".
\_ Shut up, cmlee.
\_ Good call.
\_ FreeBSD has a unified vm/buffer cache, meaning that file
caching and process memory both contend for the same physical memory
(in other words, the memory isn't segmented between the two). so
really, the answer to your question depends on how loaded the system
is, both vm and i/o-wise. now, if you don't want your file cached
(because you're only reading sequentially, or something), look at
madvise(). |