Simulator (original) (raw)

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.

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.

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>

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 ║
╚══════════════════════╧══════════╧════════════╧════════════╧════════════╧════════════╧═══════════╝