Belady phenomenon of cache algorithm and belady of cache Algorithm

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.