Skip to content

Simulator

Ben Manes edited this page Feb 20, 2023 · 42 revisions

The simulator includes a family of eviction policies and distribution generators. This helps when investigating whether a policy is a good fit for a usage scenario.

Usage

Run the Simulator in an IDE after specifying the desired configuration. Alternatively, run at the command line using:

# Single run, displays ascii table by default
gradlew simulator:run -q -PjvmArgs=<optional>

# Multiple runs, writes a combined report, and renders a chart
gradlew simulator:simulate -q \
  --maximumSize=<comma separated list; supports _ numeric literal> \
  --theme=<light, dark> \
  --jvmArgs=<optional> \
  --title=<optional>

# In both, additional configuration may be supplied as system properties
  -Dcaffeine.simulator.files.paths.0=multi3.trace.gz

The following trace formats are supported.

Traces Location Traces Location
AdaptSize author's simulator Address (UCSD) git repository
ARC author's homepage Cache2k git repository
CameLab project's homepage Cloud Physics git repository, lirs2 drive
Corda git repository GL-Cache project's homepage
Gradle git repository Kaggle project's homepage
LIRS git repository LRB author's simulator
Scarab git repository SNIA project's homepage
Tragen project's homepage Twitter project's homepage
UMass project's homepage WikiBench project's homepage

Rewriter

The rewriter utility converts traces from one format to another. This can be helpful when comparing a policy written in an alternative simulator that lacks support for a trace format.

gradlew :simulator:rewrite -q \
  --inputFormat=<trace format> \
  --inputFiles=<comma separated paths> \
  --outputFormat=<trace format> \
  --outputFile=<path>

Sample Report

Due to batching and broadcasting, the timings are only comparable when running each policy independently.

╔══════════════════════╤══════════╤════════════╤════════════╤════════════╤════════════╤═══════════╗
║ Policy               │ Hit Rate │ Hits       │ Misses     │ Requests   │ Evictions  │ Time      ║
╠══════════════════════╪══════════╪════════════╪════════════╪════════════╪════════════╪═══════════╣
║ opt.Clairvoyant      │ 48.09 %  │ 21,019,597 │ 22,685,382 │ 43,704,979 │ 18,685,382 │ 2.301 min ║
╟──────────────────────┼──────────┼────────────┼────────────┼────────────┼────────────┼───────────╢
║ sketch.WindowTinyLfu │ 45.25 %  │ 19,775,085 │ 23,929,894 │ 43,704,979 │ 19,929,894 │ 1.460 min ║
╟──────────────────────┼──────────┼────────────┼────────────┼────────────┼────────────┼───────────╢
║ irr.Lirs             │ 38.14 %  │ 16,668,577 │ 27,036,402 │ 43,704,979 │ 23,036,402 │ 1.319 min ║
╟──────────────────────┼──────────┼────────────┼────────────┼────────────┼────────────┼───────────╢
║ adaptive.Arc         │ 29.60 %  │ 12,938,241 │ 30,766,738 │ 43,704,979 │ 26,766,738 │ 1.249 min ║
╟──────────────────────┼──────────┼────────────┼────────────┼────────────┼────────────┼───────────╢
║ linked.Lru           │ 20.24 %  │  8,847,982 │ 34,856,997 │ 43,704,979 │ 30,856,997 │ 1.218 min ║
╚══════════════════════╧══════════╧════════════╧════════════╧════════════╧════════════╧═══════════╝

Clone this wiki locally