windows 缓冲区和缓存的区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3192579/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Buffer and cache Difference?
提问by Dhiva
Can anybody detail - What is the difference between Buffer and Cache in system memory?
任何人都可以详细说明 - 系统内存中的缓冲区和缓存有什么区别?
回答by marc_s
A bufferis just a container to hold data for a short period of time when more comes in at any given time than a consumer can use / process. It's a first-in, first-out situation - the data comes in, might be buffered, and goes out in the same order it came in, after a while.
一个缓冲区只是为了保持数据的容器的短时间内,当更多的在任何给定的时间比消费者可以使用/进程的用武之地。这是一种先进先出的情况——数据进来,可能会被缓冲,并在一段时间后按照进来的顺序出去。
A cacheis a storage for speeding up certain operations. Things get put in a cache, and should be retrieved from it multiple times, over and over again. There's no "flowing through the cache" kind of mechanism - data doesn't come in and go out in the same order - but it's just a holding container. The order might be anything, really - items are addressed via a key, they don't "flow through" but they are "put in" and stay there (until they're thrown out because of not being used, or because the system goes down).
一个高速缓存是加快某些操作的存储。事物被放入缓存中,并且应该从中多次、一遍又一遍地检索。没有“流经缓存”的机制——数据不会以相同的顺序进出——但它只是一个保存容器。订单可能是任何东西,真的 - 项目是通过一个键来寻址的,它们不会“流过”但它们被“放入”并留在那里(直到它们因为不被使用而被丢弃,或者因为系统下跌降落)。
回答by Martin Fabik
A buffer
is a contemporary collection of location where a huge amount of data is managed or disassembled. This may be basic for interaction with a set of collection device that needs huge blocks of information, or when data must be given in a many way than that in which it is made, or rarely considerable when less blocks are not sufficient. The advantage is here even if the buffered data are stored to the buffer in one time and get from the buffer once.
Abuffer
是管理或分解大量数据的当代位置集合。这对于与需要大量信息块的一组收集设备进行交互可能是基本的,或者当数据必须以比生成数据的方式多的方式提供时,或者当较少的块不够用时,很少有可观的。这里的优点是即使缓冲的数据一次存储到缓冲区并从缓冲区中获取一次。
A cache
, on the other side, thinks that the data will be get from the cache more one time than they are written on them.
Its aim is to less the accesses to the underlying stock.
Buffer is a programmable cache managed by the operating system in the main storage and is used to have the most necessary data from disk, so that they don't have to be gotten again from the memory. This feature is available by the operating system. While cache is in real a hardware that the CPU uses to reduced the effective memory access time.
一cache
,在另一边,认为该数据会从缓存中得到比他们都写上了他们更多的一次。其目的是减少对标的股票的访问。缓冲区是操作系统在主存储器中管理的可编程缓存,用于从磁盘中获取最需要的数据,以便它们不必再次从内存中获取。操作系统可以使用此功能。虽然缓存实际上是 CPU 用来减少有效内存访问时间的硬件。
回答by Eugene
Add something from Wikiabout the difference between Bufferand Cache.
从Wiki添加一些关于Buffer和Cache之间差异的内容。
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 an 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 reduces 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 data 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 neighboring layers.
缓冲区是传统上使用的临时内存位置,因为 CPU 指令无法直接寻址存储在外围设备中的数据。因此,可寻址存储器用作中间阶段。此外,当组装或分解大数据块(根据存储设备的要求)时,或者当数据可能以与生成顺序不同的顺序传送时,这样的缓冲区可能是可行的。此外,整个数据缓冲区通常按顺序传输(例如到硬盘),因此缓冲本身有时会提高传输性能或减少传输延迟的变化或抖动,而不是缓存,目的是减少延迟。即使将缓冲的数据写入缓冲区一次并从缓冲区读取一次,这些好处仍然存在。
缓存还提高了传输性能。增长的一部分同样来自多个小转移合并成一个大块的可能性。但主要的性能提升发生是因为很有可能多次从缓存中读取相同的数据,或者很快就会读取写入的数据。缓存的唯一目的是减少对底层较慢存储的访问。缓存通常也是一个抽象层,从相邻层的角度来看是不可见的。
回答by Wahib Idris
A buffer is just like a drum it can hold data and flush it out ... On the other hand Cache is used to make your operations faster.
缓冲区就像一个鼓,它可以保存数据并将其清除......另一方面,缓存用于使您的操作更快。