3

When does MFU (Most Frequently Used) page replacement algorithm have better performance than LRU (Least Frequently Used)? When is it worse than LRU? Where can I find information beyond the basic definition of the MFU page replacement algorithm?

Gary
  • 13,303
  • 18
  • 49
  • 71
Grisha
  • 305
  • 1
  • 4
  • 12

3 Answers3

7

Typically, I've seen an MFU cache used as the primary, backed by a secondary cache that uses an LRU replacement algorithm (an MRU cache). The idea is that the most recently used things will remain in the primary cache, giving very quick access. This reduces the "churn" that you see in an MRU cache when a small number of items are used very frequently. It also prevents those commonly used items from being evicted from the cache just because they haven't been used for a while.

MFU works well if you have a small number of items that are referenced very frequently, and a large number of items that are referenced infrequently. A typical desktop user, for example, might have three or four programs that he uses many times a day, and hundreds of programs that he uses very infrequently. If you wanted to improve his experience by caching in memory programs so that they will start quickly, you're better off caching those things that he uses very frequently.

On the other hand, if you have a large number of items that are referenced essentially randomly, or some items are accessed slightly more often than, or items are typically referenced in batches (i.e. item A is accessed many times over a short period, and then not at all), then an LRU cache eviction scheme will likely be better.

Jim Mischel
  • 131,090
  • 20
  • 188
  • 351
  • Not sure if I'm missing something but isnt this the opposite of the MRU algorithm explained - https://en.wikip`edia.org/wiki/Cache_replacement_policies#Most_recently_used_(MRU) - **MRU algorithms are most useful in situations where the older an item is, the more likely it is to be accessed** – seeker Feb 16 '19 at 01:33
  • https://en.wikipedia.org/wiki/Cache_replacement_policies#Most_recently_used_(MRU) – seeker Feb 16 '19 at 01:37
  • 1
    @seeker Yes, this answer mixes terms (the second sentence should read most _frequently_ used things) and uses MFU cache to mean a cache with a LFU replacement algorithm. In my experience, this is the incorrect term. LRU cache refers to a cache that evicts the least recently used item, so MFU cache should be a cache that evicts the most frequently used item – Kyle Chadha Aug 01 '19 at 03:32
  • Can anyone tell me why MFU isn't used very commonly in practice or potential issues that can occur? – Tianna Wrona Apr 25 '21 at 14:15
1

Least Recently Used (LRU) Page Replacement Algorithm

In this algorithm, the page that has not been used for the longest period of time has to be replaced.

Advantages of LRU Page Replacement Algorithm:

  1. It is amenable to full statistical analysis.
  2. Never suffers from Belady’s anomaly.

Most Frequency (MFU) Used Page Replacement Algorithm

Actually MFU algorithm thinks that the page which was used most frequently will not be needed immediately so it will replace the MFU page

Example: consider the following reference string:7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1

Buffer size:3 String :7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1

7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1

7 7 7 2 2 2 0 4 2 2 0 0 2 2 2 0 0 7 7 7

  0 0 0 0 3 3 3 3 3 3 3 3 3 3 3 3 3 0 0

    1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Nullpointer
  • 1,086
  • 7
  • 20
priyanka
  • 11
  • 1
0

I had been struggling to find a use case for MFU, everywhere MFU is confused with MRU. The most cited use case of MFU is:

The most frequently used (MFU) page-replacement algorithm is based on the argument that the page with the smallest count was probably just brought in and has yet to be used.

But it can clearly be understood that they are talking about MRU - most recently used cache.

What I could find was a paper which described using both MFU and LFU, most frequently used references are moved to primary cache for faster access and least frequently used references are moved to secondary cache. That's the only use case I could find for MFU.

sam
  • 13
  • 4