A full-stack cache simulator powered by Intel PIN + Python + FastAPI + Streamlit Analyze real memory traces and compare cache replacement policies interactively.
-
🔹 3-Level Cache Simulation (L1, L2, L3)
-
🔹 Replacement Policies:
- FIFO
- LRU
- Belady (Optimal)
- Custom (Stride-aware)
-
🔹 Real trace-driven simulation via Intel PIN
-
🔹 CLI + Web Interface
-
🔹 Interactive Plotly charts
-
🔹 Upload trace or generate via C++
C++ Program
↓
Intel PIN (Tracer)
↓
pin_tracer.out
↓
Python Cache Simulator
↓
FastAPI Backend
↓
Streamlit Frontend- Linux / WSL (required)
- Intel PIN
- g++, make
- Python 3.8+
sudo apt update
sudo apt install -y python3 python3-pip g++ makepip install -r requirements.txt --break-system-packagestar -xvf pin-*.tar.gz
export PIN_ROOT=/path/to/pin
export PATH=$PIN_ROOT:$PATH(Optional)
echo 'export PIN_ROOT=/path/to/pin' >> ~/.bashrc
echo 'export PATH=$PIN_ROOT:$PATH' >> ~/.bashrccd pin
make clean
makeVerify:
ls obj-intel64/pin_tracer.socd pin
g++ test_program.cpp -o a.out$PIN_ROOT/pin -t obj-intel64/pin_tracer.so -- ./a.outOutput:
pin_tracer.outcd ..
python main.pyUse:
pin_tracer.outpython -m uvicorn web.backend.server:app --reloadpython -m streamlit run web/frontend/app.pyhttp://localhost:8501- Upload
pin_tracer.out - Configure cache
- Run simulation
- Write C++ code
- Click run
- Full pipeline executes automatically
Block Size: 64
L1: 32768 (8-way)
L2: 262144 (8-way)
L3: 2097152 (16-way)
Warmup: 50000L1 ≈ 99%
L2 ≈ 60–65%
L3 ≈ ~20%| Policy | Description |
|---|---|
| FIFO | Oldest block eviction |
| LRU | Least recently used |
| Belady | Optimal (future-aware) |
| Custom | Stride/stream-aware eviction |
ca/
├── main.py
├── requirements.txt
├── README.md
│
├── pin/
│ ├── pin_tracer.cpp
│ ├── test_program.cpp
│ └── Makefile
│
├── web/
│ ├── backend/server.py
│ ├── frontend/app.py
│ └── simulator/cache_sim.py- Always run from project root
- Use
pin_tracer.outconsistently - Large traces (>200MB) may fail upload
- PIN required → Linux only
- Write-back / write-through policies
- Non-inclusive caches
- ML-based replacement
- Docker support
Aryan
If this helped you:
👉 Give it a star ⭐ 👉 Share it 👉 Fork it
A realistic, extensible system that bridges cache theory + real-world execution using trace-driven simulation.