[Gllug] Difference between "buffers" and "cached"?

Adrian McMenamin adrian at mcmen.demon.co.uk
Fri Jan 27 09:39:07 UTC 2006


On Fri, 27 January, 2006 6:41 am, John Winters wrote:
> I recently put an extra gig of RAM in my server bringing it to 1.5G, for
> no better reason than that the motherboard has three memory slots and
> 512M DIMMs seem to come free with the cornflakes these days.
>
> I tested the new memory with memtest before I booted up and all seems to
> be fine.  Very quickly after the system started work I noticed that most
> of the memory had been swallowed up as "cached" when viewed in top, and
> that's how it seems to stay most of the time.  However, first thing in
> the morning I find that more of the memory (say half a gig) is taken up
> as "buffers" and only about 350M as "cached".  Then during the day
> "cached" drifts up and "buffers" drifts down.
>
> Can anyone explain the difference between "cached" and "buffers" please?
>
>
Once upon a time I wrote a filesystem and this is from memory - which mean
it may be all wrong.

But --- the nature of disks is that they are read off in blocks (ie you
have to read in a large block of data just to get at any one byte).

The filsystems on your system buffer this input so when you ask for a
read, the data is read into a buffer and you can keep on using that buffer
until you write, whereupon you can assume - in userland - that the updated
data has been written out to the disk. But you cannot assume that until
you have explicitly written the buffer back to the disk.

However those reads and writes are also cached by the kernel to ensure
that disk reads and writes are handled in the most efficent way. You don't
actually need the cache (though you do need the buffers) but it does make
your system much more efficent.

I found on my system - a Dreamcast with a flash card memory system - that
cached writes typically happened 2 seconds after the buffers were written
- the extra delay wouyld have a big advantage with a flash system because
if you were rapidly manipulating the data then number of writes would be
minimised (flash has a limited number of writes available before it fails)

HTH

-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list