Cache capacity

Dynamic randomly accessed memory (DRAM) is very slow. This can result in very different performance results during benchmarking.

There are two suggested strategies to this pitfall:

  • Run multiple benchmarks with varying problem sets. Keep track of your memory footprint during tests.
  • Use the @State annotation to dictate the JMH state. This annotation is sued to define the instance's scope. There are three states:
    • Scope.Benchmark: The instance is shared across all threads that are running the same test.
    • Scope.Group: One instance is allocated per thread group.
    • Scope.Thread: Each thread will have its own instance. This is the default state.

Get Java 9: Building Robust Modular Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.