Nepedia
Back to Discover
Fluent Reader
💻

Cache replacement policies

technology Maturity 7-9 Next article →

Computers use a fast storage area called a cache to work quickly. This cache keeps data that is used often or very recently. Using a cache makes a computer faster because it is cheaper to access. However, a cache has a limited size. When the cache is full, the computer must choose something to discard. This choice is made by a cache replacement policy. These policies are sets of instructions that manage the information in the cache.

Lruexample
Lruexample

There are many ways these policies work. One way is called First In, First Out, or FIFO. This method removes items in the exact order they were added. Another way is Last In, First Out, or LIFO. This works like a stack where the newest item is removed first. Some systems use Random Replacement, which picks an item to toss by chance. This is a simple method used in ARM processors.

Lruexample
Lruexample

Many computers use a policy called Least Recently Used, or LRU. This method tracks when items are used. It discards the item that has not been used for the longest time. It can be hard to do because the computer must keep track of usage. Because of this, many designers use Pseudo-LRU instead. This is a simpler version that uses just one bit per item. It uses a binary tree of pointers to find what to replace.

Lruexample
Lruexample

Researchers have studied many different strategies over the years. In 1985, Chou and DeWitt spoke at the 11th VLDB conference. They said Most Recently Used, or MRU, is best for certain patterns. MRU discards the item used most recently. This is helpful when a computer scans files in a loop. Other experts like Paul V. Bolotoff wrote about cache principles in 2007. They noted that streaming video can sometimes fill a cache with data that is only used once.

Mruexample
Mruexample

Understanding these policies helps us see how computers handle hard jobs. A perfect policy is called Bélády's algorithm. It would discard the item that is not needed for the longest time. This is called the clairvoyant algorithm because it knows the future. However, computers cannot actually predict the future, so this is not possible in real life. We can only compare our real policies to this ideal version. This helps us find the best balance between speed and accuracy.

Beladysalgoworking
Beladysalgoworking
385 words

Where will your curiosity go next?

Keep exploring at your chosen reading level.

🖼️ Images & Media (7)
File:Beladysalgoworking.png
Beladysalgoworking.png
File:Lruexample.png
Lruexample.png
File:Mruexample.png
Mruexample.png
File:Plruexample.png
Plruexample.png
File:Mockingjay Description.svg
Mockingjay Description.svg
File:LIRSalgoworking.png
LIRSalgoworking.png
File:MultiQueueReplacementAlgortithm.jpg
MultiQueueReplacementAlgortithm.jpg
More to explore

What is Nepedia?

A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.