CacheSim is a tool to evaluate the performance of various classical caching algorithms on small edge devices. The tool implements nine caching algorithms including FIFO, LRU, LFU, 2Q, ARC, LIRS, CLOCK-Pro and TinyLFU.
- Device: Odroid-c4
- OS: Ubuntu 20.04.4 LTS
- Processor: Cortex-A55
- Memory: 3.6 GiB
- Storage: SD, eMMC
Note: VMware are not recommended, code may report errors.
- C++: 17 or later
- Python 3.7 or later
- Storage: Any two flash devices with performance differences
- C++ Package: uuid-dev
Refer to this section if you want to debug your code on a PC and not for actual edge device cache testing. If you don't need it, then skip this section.
- Check trace
Ensure that the trace data is located in the directory CacheSim/trace
and that trace is at the same level as src
. Create the directory trace
if it does not exist.
cd CacheSim
sudo rm -rf trace
mkdir trace
Copy the CacheSim/sample/125MB
folder to the CacheSim/trace
directory if you want to test the nocache
and ycsb
modes, or copy the CacheSim/sample/real_trace_3
folder to the trace directory if you want to test the real
and montecarlo
mode.
cp -r sample/125MB trace
or
cp -r sample/real_trace_3 trace
- Compile
Make sure you're in a linux environment. Then compile.
cd CacheSim/src
sudo g++ -g -std=c++17 -o main main.cpp -luuid
- Run
sudo ./main <run_mode>
Note:
run_mode
includesnocache
,ycsb
,real
andmontecarlo
.
Note: eMMC here can be the better performing of the two types of flash memory.
- List all available disk partitions on the system
fdisk -l
- Create disk partitions
fdisk /dev/mmcblk0
Enter the following commands in sequence
n
p
1
2048
w
- Format the newly created partition
/dev/mmcblk0p1
as ext4 file system
mkfs -t ext4 /dev/mmcblk0p1
sudo date -s "YYYY-YY-DD HH:mm:ss"
- View all disks recognized by the system
fdisk -l
- Temporarily mount eMMC to /mnt/eMMC
sudo mount /dev/mmcblk0p1 /mnt/eMMC
- Check disk mounts
lsblk
Place the trace
file in the CacheSim\trace
directory. Create the directory trace
if it does not exist.
Note: Only one set of Trace can be placed at a time。
Start power tester.
cd CacheSim/scripts/bash
bash cpu_mem_disk.sh
Note: manually conduct
Ctrl+C
to terminate code at the end of its run inTerminal 2
.
- Go to the source code directory
cd CacheSim/src
- Compile
main.cpp
sudo g++ -std=c++17 -o main main.cpp -luuid
Note:
-std=c++17
is for CLOCK-Pro
- Execute
sudo ./main <run_mode>
Note:
run_mode
includesnocache
,ycsb
,real
andmontecarlo
.
If you want to debug a memory leak, replace the normal run command with the following:
sudo valgrind --tool=memcheck --leak-check=full --show-leak-kinds=all --track-origins=yes ./main <run_mode>
In addition, CacheSim has good scalability and supports extending new caching algorithms and designing new test flows. To add a new cache algorithm implementation, follow these steps.
- Implement the new caching algorithm in the
src/cache/
folder. - Inherit the base
class Sl
in thesrc/simulator/
folder, call the new caching algorithm, implement the interfaces of the baseclass Sl
(isCached()
,accessKey()
andgetVictim()
). - Add the new caching algorithm to
src/utils/policy.h
. - Add the new caching algorithm to the
runYcsbOnce()
andrunRealOnce()
functions insrc/utils/run.h
. - (Optional) Write new own test run function in
src/utils/run.h
and call it insrc/main.cpp
.
The following is a list of code repositories and blogs referenced for caching algorithm implementations.
- FIFO-LFU-LRU: https://github.com/vpetrigo/caches
- 2Q: https://github.com/Mirageinvo/2Q-cache & https://blog.csdn.net/Sableye/article/details/118703319
- ARC: https://github.com/anuj-rai-23/Adaptive-Replacement-Cache-ARC-Algorithm
- LIRS: https://github.com/374576114/cache & https://blog.csdn.net/z69183787/article/details/105534151
- Clock-Pro: https://github.com/maximecaron/ClockProCPP
- TinyLFU: https://github.com/vimpunk/tinylfu
For further details, refer to: https://github.com/yxchencs/YCSB-KVTracer.
-
Nexus5_Kernel_BIOTracer_traces - Nexus 5 Smartphone Traces
- Trace sample: log106_Messaging.txt
- Cite: I/O Characteristics of Smartphone Applications and Their Implications for eMMC Design https://ieeexplore.ieee.org/abstract/document/7314143
-
- Trace sample: mobi.trace.0.txt
- Cite: Q. Yang, R. Jin, and M. Zhao, “SmartDedup: Optimizing Deduplication for Resource-constrained Devices,” Proceedings of USENIX Annual Technical Conference (USENIX ATC ’19), July 2019.
-
- Trace sample: baidutieba-4h.txt
- Cite: Bo Mao, Suzhen Wu, Hong Jiang, Xiao Chen, and Weijian Yang. Content-aware Trace Collection and I/O Deduplication for Smartphones. In Proceedings of the 33rd International Conference on Massive Storage Systems and Technology (MSST'17), Santa Clara, CA, USA, May 15-19, 2017.
The main data tested in this project are as follows:
main.cpp
- Hit ratio
- Block hit ratio
- Trace hit ratio
- Read/Write hit ratio
- Latency
- Total time
- Average time
- P95/P99 latency
- Bandwidth = total size / total time
- Average size = total size / request number
- Hit ratio
cpu_mem_disk.sh
- Average cpu usage
- Average memory used
- Disk read/write
- U96P-B power meter
- Average power
- Total Energy
If you use CacheSim in your research, please cite our SoftwareX '25 paper.
Liu, J., Chen, Y., & Ding, H. (2025). CacheSim: A cache simulation framework for evaluating caching algorithms on resource-constrained edge devices. SoftwareX, 29, 102018.
GNU General Public License v3.0