Inamul07 / Cache_Analysis

Analysis of Different Cache Replacement Algorithms

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cache Analysis

In this Repository

  • Least Recently Used (LRU)
  • Clock Page Replacement
  • 2Q
  • Adaptive Replacement Cache (ARC)

Objectives

  • This repository aims to analyse different page replacement algorithms.
  • This repository contains implementations of the said page replacement algorithms, created in accordance with the relevant research papers.

References

How to use this project

  • Clone this Repository.
    $ git clone git@github.com:Inamul07/Cache_Analysis.git
    $ cd Cache_Analysis
  • Edit the main.c file to include the required replacement algorithm.
  • Then run this command in terminal,
    $ make
    

Algorithm Methods

Algorithm cache_name
Least Recently Used LRU
Clock Page Replacement CLOCK
Two Queue TWO_QUEUE
Adaptive Replacement Cache ARC

Methods

  • cache_init(cacheType cache_name, int capacity)
    • Initializes the respective cache with given capacity.
    • returns generic_cache*.
  • cache_access(generic_cache* cache, int page)
    • Performs the relevant cache operation.
    • Keeps an internal count of number of hits and misses.
    • returns void.
  • cache_analysis(generic_cache* cache)
    • Prints the buffer, total references, number of hits and misses and hit ratio.
    • returns void.
  • cache_print_buffer(generic_cache* cache)
    • Prints the buffer at that current state.
    • returns void.
  • cache_put_array(generic_cache* cache, int pages[], int size)
    • Performs the relevant cache operation for each data item from pages in a linear fashion.
    • returns void.
  • cache_destroy(generic_cache* cache)
    • free the memory allocated by the cache.
    • returns void.

For Cache Initialisation, Pass the appropriate cache_name to the cache_init() method. ( Refer Table for appropriate cache_name )
Example:

  • For Initialising LRU with a capacity of 3, cache_init(LRU, 3);
  • For Initialising TWO_QUEUE with a capacity of 5, cache_init(TWO_QUEUE, 5);.

Benchmarking

  • The data folder, at the root, contains test data generated by DataGenerator.java.
  • We use Google benchmark to benchmark the Cache Replacement Algorithms.
  • To run bench mark, execute the following command
    $ make benchmark
  • This prints the time taken by the cache algorithms along with their respective Hit Ratio.

About

Analysis of Different Cache Replacement Algorithms


Languages

Language:C 91.1%Language:C++ 4.3%Language:Java 3.2%Language:Makefile 1.4%