This is LFU (least frequently used) cache emulation written in C++. This type of cache stores memory pages with high hit rate and replaces pages with low frequency with the new ones in case there is not enough free space to fit them both. Cached pages have low access time and others are loaded with slow lookup method provided by user.
You're expected to type the following on startup (see Running section for more):
<cachesize> <number of keys>
<key1> <key2> <key3> <etc>
cachesize
stands for the cache maximum capacity, number of keys
- number of cache read attempts, keyn
- id of the page to be red in current read iteration. After you're done, hwc-cache
will simulate the process and display just one value - number of cache hits for current algorithm.
Download this repository with
git clone https://github.com/nerett/hwc-cache.git
Install required packages automatically with
make install-dependencies-pkg PACKAGEMANAGER=<your-package-manager-name> #apt is used if PACKAGEMANAGER is not defined
...or install them manually with your distro package manager (check list here).
Build hwc-cache
as a standalone program with
make MODE=DEBUG #or MODE=RELEASE; MODE=RELEASE if not defined
You can run builded release/debug version of standalone hwc-cache
with
make run-lfu MODE=DEBUG #MODE=RELEASE if MODE is not defined
Use rund
instead of run
to run with valgrind
...or run this binary with manually from project directory.
There are built-in end-to-end test. You can run current test pack for LFU cache with
make test-lfu
Test pack for FLU cache is located in test/lfu_testdata/
. There are 2 types of files: *.in
for input data and *.exp
for expected result. All of these files are scanned automatically on startup and added to the current test sequence.
To totally rebuild the project run
make clean
make MODE=<modename>
This project actually depends on libc
and building requires make
, g++
and git
(it can also require valgrind
installed to use rund
target).
This section isn't done yet.
This program was written during MIPT Vladimirov's cource.