The computer, alas, does not instantly execute commandswhich receives from people. To speed up this process, a number of tricks are used, and the place of honor among them belongs to caching. What it is? What is cached data? How does this process actually happen? What is cached data in a Samsung smartphone, for example, and do they differ in some way from that in a computer? Let's start getting answers to these questions.
What is a cache?
Process of use
Data update
When using, say, a web browserA local cache is checked to find a copy of the page. Given the limitations of this type of memory, in case of a miss, a decision is made to discard some of the information in order to free up space. To decide what will be replaced, use different algorithms for crowding out. By the way, if we talk about what is cached data on the "Android", then for the most part they are used to work with pictures and application data.
Write policy
- Immediate recording. Each change is synchronously recorded in the main memory.
- Delayed or write back.Data is updated periodically or upon request from the client. To keep track of whether a change has been made, use a sign with two states: "dirty" or changed. In case of a miss, two calls can be made to the main memory: the first is used to write data that has been changed from the cache, and the second is to read the necessary element.
Может быть и такое, что информация в intermediate buffer becomes irrelevant. This happens when data changes in the main memory without making adjustments to the cache. For coherence of all editing processes, coherence protocols are used.
Modern challenges
Synchronize data between different buffers
The cache is useful when one, and how to maintain the effectiveness of this technology, if they are many? This problem is solved by buffer coherence. There are three options for data exchange:
- Inclusive. Cache can behave as you like.
- Exclusive. Developed for each case.
- Non-exclusive The standard is widespread.
Caching levels
- L1 cache. The fastest cache level is first.In fact, it is part of the processor, since it is located on one chip and belongs to functional blocks. Usually divided into two types: instruction and data cache. Most modern processors without this level do not work. This cache operates on the processor frequency, so it can be accessed every clock cycle.
- L2 cache.Usually located together with the previous one. It is a separate memory. To find out its size, it is necessary to divide the entire volume used for caching data by the number of cores in the processor.
- L3 cache. Slow, but the largest dependent cache. Usually more than 24 MB. Used to synchronize data that comes from various second-level caches.
- L4 cache.Use is justified only for high-performance multiprocessor mainframes and servers. It is implemented as a separate chip. If you ask a question about what data caching is in the Samsung smartphone and you are looking for this level in it - I can say that for 5 years you are definitely in a hurry.
Cache associativity
This is a fundamental characteristic.Associativity of cached data is necessary to display logical segmentation. It, in turn, is necessary due to the fact that sequential enumeration of all available lines takes dozens of cycles and reduces all advantages. Therefore, a tight binding of the RAM cells to the cache data is used to shorten the search time. If we compare intermediate buffers, which have the same volume, but different associativity, then the one for whom it is large, will work less quickly, but with significant specific efficiency.