Code for Sampling-Based
Adaptive Replacement (SBAR)
(Works on Linux. Known to not work on Sun machines with
Unix)
Download:
To execute the sample code for sbar, download the
following files:
Sample runs:
For testing cachesim, type "make test". This should simulate five cache configurations:
1.
The baseline 1MB 16-way LRU-managed cache
./cachesim
-mtdrepl LRU art_00.atr.gz
=======================
Count: 1000001
Miss: 770365 (77.04%)
=======================
2. A 1 MB 16-way cache with RANDOM replacement
./cachesim -mtdrepl RND
art_00.atr.gz
=======================
Count: 1000001
Miss: 485051 (48.51%)
=======================
3. A 1 MB 16-way cache with LFU replacement
./cachesim -mtdrepl LFU
art_00.atr.gz
=======================
Count: 1000001
Miss: 326694 (32.67%)
=======================
4. A 1MB 16-way cache with SBAR (selecting between the default
LRU policy and ATD's RND policy using 32 leader sets)
./cachesim -mtdrepl LRU -leaders 32
-atdrepl RND art_00.atr.gz
=======================
Count: 1000001
Miss: 468935 (46.89%)
SBAR used MTD policy: 24.5%
SBAR used ATD policy: 75.5%
=======================
5. A 1MB 16-way cache with SBAR (selecting between the default
LRU policy and ATD's LFU policy using 32 leader sets)
./cachesim -mtdrepl LRU -leaders 32
-atdrepl LFU art_00.atr.gz
=======================
Count: 1000001
Miss: 355329 (35.53%)
SBAR used MTD policy: 16.7%
SBAR used ATD policy: 83.3%
=======================
The example shows how the code can be used to select between LRU and
RND (or LFU) using dynamic set sampling with 32 leader sets. SBAR
can outperform the component policies because it dynamically selects
the policy best suited to paritcular phase of the program.
In
general, the framework can be used to dynamically select between any
two replacement policies. For example, to select between LRU and
any policy X, first implement the policy X in the code. Then, use LRU for mtdrepl and X for
atdrepl. The code can
also be extended to support more than two replacement policies.