Skip to content

Tracing

Ben Manes edited this page Mar 27, 2015 · 4 revisions

Cache tracing can be enabled to capture information on how well an application utilizes its caches. Typically caches are either too small due to statistics not being monitored, or too large due to over sizing to increase the hit rate. Running the simulator on traced data enables adjusting the cache size based on both the hit rate and active content ratio.

Tracing is captured automatically if enabled at the application level. The caches themselves do not require any special configuration. By default a cache instance's name is inferred by a best effort guess of the calling class's name. The name can be explicitly set using Caffeine.name(Supplier).

The tracing package is enabled if a Java ServiceLoader service is registered with the application in a resource file located at META-INF/services in one of its jars. The system property caffeine.tracing.enabled can be set to false to ignore the discovered implementation.

AsyncTracer

AsyncTracer is a lightweight implementation based on the LMAX Disruptor library that logs the events to a local file. It is configured using the following system properties:

  • caffeine.tracing.file: The path to the tracing output file
  • caffeine.tracing.format: The format is either text or binary
  • caffeine.tracing.bufferSize: The size of the disruptor's ringbuffer