LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Difference between cache and buffers (https://www.linuxquestions.org/questions/linux-newbie-8/difference-between-cache-and-buffers-4175424930/)

sluge 08-31-2012 04:39 AM

Difference between cache and buffers
 
Hello!
vmstat shows statistics about cache and buffers, but where the difference between them?

GlennsPref 08-31-2012 06:55 AM

I think the buffers are in cache (ram) the buffer may have a size (rhetrofit/back(ward) tech/compatibility),

but the cpu may not need the buffer set aside for it(the data in cache) if the cpu/ram/HDD/Inet is fast enough.

Streaming instead of buffering, but buffering anyway in case (may cause double handling, busy cpu, no room for sheduled tasks (?)).

Internet speeds are quite fast (not fast like South Korea,)

and in most instances the bandwidth is sufficeint to deliver the goods on time.

You need a bandwith tester for your graphics and other gaming devices, like sound.

No good if the picture is perfect but there is a delay with key-presses, and/or sound delays.

Can't remember why I started this post, Happy Friday to you all.

Cheers Glenn

pan64 08-31-2012 07:42 AM

probably: http://en.wikipedia.org/wiki/Cache_%28computing%29
http://en.wikipedia.org/wiki/Data_buffer

johnsfine 08-31-2012 08:10 AM

Quote:

Originally Posted by sluge (Post 4768977)
vmstat shows statistics about cache and buffers, but where the difference between them?

I'm not sure. I wouldn't answer at all if you hadn't already gotten two really terrible answers.

I think the difference arises because of the fact that the OS works in 4KB chunks, but files are not necessarily aligned on 4KB boundaries on the media.

I think cache holds chunks of file that are 4KB aligned within the file, while buffers hold chunks of the filesystem that are 4KB aligned in the filesystem, but not in a specific file.

1) I might be totally wrong. I never looked at the relevant code. I'm repeating/simplifying plausible info that I read elsewhere.

2) The 4KB number is an x86 standard, not a Linux standard. It may be some other value for Linux on some other architecture.

pan64 08-31-2012 12:17 PM

Quote:

Originally Posted by johnsfine (Post 4769166)
I'm not sure. I wouldn't answer at all if you hadn't already gotten two really terrible answers.

I do not think wiki is terrible. In general cache is used to duplicate data in memory to have much quicker access (for frequent usage). It is explained on that wiki page with a lot of examples. Also at the end of the page there is a small explanation about the difference between buffers and caches.

johnsfine 08-31-2012 02:04 PM

Quote:

Originally Posted by sluge (Post 4768977)
vmstat shows statistics about cache and buffers

Quote:

Originally Posted by pan64 (Post 4769349)
I do not think wiki is terrible.

I didn't really intend to start a fight. I just thought I should explain why I was posting rather than waiting for someone who really knows the answer.

I didn't say wiki was terrible. I'm not very impressed with those two articles, but that is irrelevant. If those two articles were great descriptions of the generic computer terms "buffer" and "cache", that still wouldn't change the fact that linking to generic info (containing no Linux specifics) is a terrible answer for a question that is very specific to Linux.

If you thought the difference between "buffer" and "cache" in some generic context was relevant to the difference between "buffer" and "cache" in Linux, you were mistaken.


All times are GMT -5. The time now is 09:00 AM.