Class ClockProPolicy

  • All Implemented Interfaces:
    Policy, Policy.KeyOnlyPolicy

    public final class ClockProPolicy
    extends Object
    implements Policy.KeyOnlyPolicy
    The ClockPro algorithm. This algorithm differs from LIRS by replacing the LRU stacks with Clock (Second Chance) policy. This allows cache hits to be performed concurrently at the cost of a global lock on a miss and has the worst case time of O(n) on eviction due to queues being scanned.

    ClockPro uses three hands that scan the queue. The hot hand points to the largest recency, the cold hand to the cold entry furthest from the hot hand, and the test hand to the last cold entry in the test period. This policy is adaptive by adjusting the percentage of hot and cold entries that may reside in the cache. It uses non-resident (ghost) entries to retain additional history, which are removed during the test hand's scan. The algorithm is explained by the authors in CLOCK-Pro: An Effective Improvement of the CLOCK Replacement and Clock-Pro: An Effective Replacement in OS Kernel.

    • Constructor Detail

      • ClockProPolicy

        public ClockProPolicy​(Config config)
    • Method Detail

      • stats

        public PolicyStats stats()
        Description copied from interface: Policy
        Returns the cache efficiency statistics.
        Specified by:
        stats in interface Policy
      • finished

        public void finished()
        Description copied from interface: Policy
        Indicates that the recording has completed.
        Specified by:
        finished in interface Policy