This is an improvement over ARC by combining ARC with Clock (second-chance) cache replacement algorithm. Like ARC, there are two LRU queues and each queue is separated from cache () and directory (). But instead of a simple queue, the LRU are now implemented in a circular queue with a “hand” pointing to one of the items. And each item has a R-bit to flag that the item has been accessed recently.

The algorithm is as follows:

  • If there is a cache hit (), assert the R-bit of the item
  • If there is a cache miss (not in ), make room to load the item into the cache
    • If , then the cache is full. We loop until a page is moved from to or from to , as described in the following
      • In every loop, if , and the item pointed by the “hand” in has R-bit asserted, it is moved to the tail (i.e. the one behind the “hand”) position in with the R-bit cleared
      • Alternatively, if , but the item pointed by the “hand” in has R-bit cleared, it is moved to the MRU position of B1 and the loop terminates
      • Alternatively, if , and the item pointed by the “hand” in has R-bit asserted, its R-bit will be cleared and the “hand” moves forward by 1
      • Alternatively, if , but the item pointed by the “hand” in has R-bit cleared, it is moved to the MRU position of B2 and the loop terminates
  • If , discard the an object from or if , discard an object from according to the second-chance priority
  • Now the cache shall have room for the new entry
    • If the item is a directory miss, load the object into (from ) with R-bit cleared.
    • If the item is a directory hit but a cache miss, adjust the parameter according to ARC and move the object to the “tail” position of with its R-bit cleared

Comparing LRU, ARC and CAR:

  • LRU captures recency but not frequency. ARC improves over this
  • A scan, i.e. a sequence of one-time-use object reference can pollute the LRU. ARC solves the problem by a dual LRU.
  • LRU requires items be moved on every access, which is expensive. The Clock algorithm gives a lightweight solution.

And therefore, CAR combines ARC and Clock and it solves all the above problems.

Bibliographic data

@inproceedings{
   title = "CAR: Clock with Adaptive Replacement",
   author = "Sorav Bansal and Dharmendra S. Modha",
   booktitle = "Proc. 3rd USENIX Conference on File and Storage Technologies (FAST)",
   pages = "187--200",
   year = "2004",
   address = "San Francisco CA",
}