LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   free, buff, cache memory on Debian (https://www.linuxquestions.org/questions/linux-software-2/free-buff-cache-memory-on-debian-814906/)

brgsousa 06-18-2010 07:33 AM

free, buff, cache memory on Debian
 
Hi,
What it's the difference between buff(ered) and cache portions of memory?

Code:

# vmstat
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
 r  b  swpd  free  buff  cache  si  so    bi    bo  in  cs us sy id wa
 0  0      0 1399208  16760 143932    0    0    47    56  525  190  9  1 88  3

regards

pljvaldez 06-18-2010 10:33 AM

From wikipedia
Quote:

The terms "buffer" and "cache" are not mutually exclusive and the functions are frequently combined; however, there is a difference in intent.[citation needed] A buffer is a temporary memory location, that is traditionally used because CPU instructions cannot directly address data stored in peripheral devices. Thus, addressable memory is used as intermediate stage.

Additionally such a buffer may be feasible when a large block of data is assembled or disassembled (as required by a storage device), or when data may be delivered in a different order than that in which it is produced. Also a whole buffer of data is usually transferred sequentially (for example to hard disk), so buffering itself sometimes increases transfer performance or reduce the variation or jitter of the transfer's latency as opposed to caching where the intent is to reduce the latency. These benefits are present even if the buffered data are written to the buffer once and read from the buffer once.

A cache also increases transfer performance. A part of the increase similarly comes from the possibility that multiple small transfers will combine into one large block. But the main performance-gain occurs because there is a good chance that the same datum will be read from cache multiple times, or that written data will soon be read. A cache's sole purpose is to reduce accesses to the underlying slower storage. Cache is also usually an abstraction layer that is designed to be invisible from the perspective of neighbouring layers.
If you're looking for memory that's free for application use, I typically use free -lm and read the line that begins with "-/+ buffers/cache".

johnsfine 06-18-2010 11:51 AM

Quote:

Originally Posted by pljvaldez (Post 4007671)

I don't think that generic answer is very effective for this Linux question.

That Wikipedia page looked like it was influenced by the meanings of buffer vs. cache that are specific to Linux. But it certainly wasn't focused on those meanings.

My understanding/recall of what I've read on this question (but don't remember where) is:

Cache holds only aligned page size chunks of files. Buffers are used in various situations in which aligned page size chunks of files are not practical. I think the buffers are tied to chunks of the media (the partition for a typical filesystem) rather than chunks of a specific file.

But don't trust me on the above, because I'm not sure I trust the pages I read that gave me that info and I'm not sure I understood/recall them accurately. So I'm just posting this while we wait for someone who actually knows to post something more accurate.

pljvaldez 06-18-2010 11:56 AM

Quote:

Originally Posted by johnsfine (Post 4007739)
I don't think that generic answer is very effective for this Linux question.

I should probably start putting a general disclaimer on anything I quote from wikipedia. :D After all, it is an imperfect reference...


All times are GMT -5. The time now is 04:45 AM.