Belady phenomenon of cache algorithm and belady of cache Algorithm
Preface
When the FIFO algorithm is used as the missing page replacement algorithm, the number of missing pages allocated increases, but the missing page rate increases. This exception is calledBelady Anomaly.
Although this phenomenon indicates that the scenario is due to the absence of page replacement, when the FIFO algorithm is used as the cache algorithm,Increase the cache capacity, but the cache hit rate will also decrease.. This is also a concept I encountered when learning cache algorithms, although summarized.
I. Example
Suppose we have the string "dcbadcedcbae". The page replacement algorithm uses the FIFO algorithm. Now there are two memories: three pages and four pages. The result is as follows:
The figure clearly shows that the number of missing pages in the former is 9, and the number of missing pages after the increase is 10.
Ii. Analysis
Let's take a closer look at the number of pages in the memory at every moment. For example, at the moment, the pages of 3 pages of memory are a, c, and B, the pages of 4 pages of memory are d, c, B, And a, and the three pages of memory are subsets of 4 pages of memory, so if 3 is not missing, 4 is certainly not missing.
However, for example, at the moment, the 6-page memory is e, d, and c, the 4-page memory is e, c, B, and a, and the 3-page memory is not a subset of the 4-page memory, this means that when page 4 is missing, page 3 is not necessarily missing. Time 7 is the same as time 10.
Iii. Conclusion
If a smaller set of pages in the memory is a subset of a larger set of pages in the memory, this algorithm is called stack algorithm. It can be proved that the stack algorithm (such as LRU) does not have the belady phenomenon, and the FIFO will appear.
Iv. References
1. Belady's Anomaly