Skip to content

BileyHarryCopter/LFUDA_BELADY_CACHE

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LFUDA and BELADY cache implementations

For what?

Firstly, it's just interesting. Secondly, this is the first practice task on C++ based course by K.I.Vladimirov.

LFUDA cache implementation with complexity O(logM)*

Main structure of cache represents realisation of structure from this source. But LFUDA decision suppose include a technology of dynamic aging, which needed of sorted list of weights (for more information check this article). For this sorting it's be suggested to use red-black-tree from std::map.

BELADY cache implementation with complexity O(logM)*

  1. Filling the hashmap from input by hash pair: key and iterator to the list with number of position element with the key in requests (FP = position in the future).
  2. Cache space is a map (rbtree) which contains number of nodes less than cache's capacity. The nodes are placed by first future position (from left to right = from the nearest to the farest).
  3. PUSH:
    1. Cache is full. We need to evict the farest nodes in the future - access to the last element in the map, erase it from the hashmap by its key, erase it from the map and decrease the size of cache
    2. For requested page we access to it's node by key in hashmap and find the FP. After that there are 2 cases: if FP is more than other FP in the cache (we do not need in eviction - in this cace we do not even need to evict a node if cache is full), and if FP belong to diapazon of cache FPs - insert in rbtree execute for O(log N)

That is all about algorithm in general ideas

Hot to install

  1. First of all, clone repo:
   git clone https://github.com/BileyHarryCopter/LFUDA_BELADY_CACHE.git
   cd LFUDA_BELADY_CACHE/
  1. After that you can make:
   cmake -B build
   cd build/[cache]
   cmake --build .

Where [cache] can be lfuda or belady.

  1. Congratulations! Now you have executable file which call [./cache]

How to launch tests

  1. From root directory move to test and write down:
   ./test.sh [cache] [mode]

Where [cache] can be lfuda or belady. [mode] can be two variants: [based] (launch basic test for cache) or any positive integer number [N] (launch test generation of [N] tests)

Comparison LFUDA with ideal cache BELADY

It is still not ready, because I wanna do it special

NOTE

* M - capacity of cache

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published