[ILUG] Managing the Filesystem cache . . .
wesley at yelsew.com
Mon Nov 8 19:49:45 GMT 1999
On Mon, Nov 08, 1999 at 05:19:23AM -0600, John_White at dell.com wrote:
> Does anybody know if there is a way of telling a system not to use more than
> n% of ram to cache the filesystem ?
Don't think so. I can't think of any reason (apart from testing) why one
might want to do something like this! :-) Of course, you must have a
reason or you wouldn't be asking...
I did find, though, that on a big memory machine (3GB) with a "bigmem
patch" and only CONFIG_1GB enabled, linux would only use 1GB for buffers
and cache. Similarly, it would only use 2GB for these with CONFIG_2GB,
even though in both cases all memory was available.
Interestingly (or not) a 512MB ramdisk I had defined counted towards
buffers, so that left only 512MB for caching/buffering with CONFIG_1GB
in force. Not good. Enabling the hidden CONFIG_3GB option allowed for
lots of caching & buffering, thankfully, which was why I got so much
memory in the first place. It's a Dell 6300, curiously. :-)
Perhaps creating a ramdisk that is 1024MB-xMB might do the trick, regardless
of how much RAM you actually have, where x is the amount of memory to which
you wish to restrict your buffers & cache. I imagine you'd need lots of swap,
though and plenty of patience as the ramdisk is being "formatted".
> Also, does anybody know of a way to get the cache to be fulshed to disk (a
> la sync)
> and also have the kernel free the associated memory ?.
Interesting one. I believe that under linux the difference between "cache"
and "buffers" is that "cache" is a cache (sorry) of data previously read *in*
and "buffers" is a cache (sorry again) of data written *out*. As such,
flushing "cache" makes no sense - it can just be forgotten about - whereas
flushing "buffers" does make some sense, athough very little of "buffers"
will actually be dirty. If any. Probably.
One way to get rid of your cache and buffers is to write a wee program
that allocates plenty of memory, *does something with it* and exits.
It's important that something be done with the memory, though, otherwise
it won't actually get allocated. The usual something is filling it with
I'm sure there's a "proper" way to do all you ask. I'm keen to learn
what it is... :-)
PS. Don't take any of the above as gospel. It's just what I've surmised from
trying to figure out what all the numbers mean. Hopefully somebody will
correct me where I'm wrong.
PPS. This reminds me of a joke I heard about comp.lang.perl - where
allegedly the best way to get one's question answered was not just to post
it, but to post an incorrect answer as a different person. :-)
More information about the ILUG