Skip to content

Simulator

Ben Manes edited this page Sep 14, 2024 · 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

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

# In both, additional configuration may be supplied as system properties
  -Dcaffeine.simulator.files.paths.0=multi3.trace.gz
# and custom jvm arguments can be provided
  -PjvmArgs=-Xmx6g

The following trace formats are supported.

Traces Location Traces Location
AdaptSize author's simulator Address (UCSD) git repository
ARC git repository Baleen project's homepage
Cache2k git repository Cachelib project's homepage
CameLab project's homepage Corda git repository
GL-Cache project's homepage Gradle git repository
Kaggle project's homepage libCacheSim author's simulator
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