Avoid full cache scanning for pruning

The full cache scanning should be avoided at all costs
because of the massive CPU and JVM heap utilisation due
to the deserialisation of the cached values.

The prune() of the cache cannot rely on any ordering
of entries and therefore needs another data structure
to remember the historical insertion ordering of the

Use an in-memory linked hash set so that MRU keys are propagated by
remove-add on each key access to the tail of it whereas LRU key is
always available as a head key (therefore it is cheap to remove LRU
keys). In addition to key store also the value insertion time so that
expiring entries for maxAge is also possible.

TODO: The queue is currently in memory which isn't going
to work across restarts. The queue needs to be persisted
to disk as a circular file with automatic reorganiation.

Bug: Issue 15121
Change-Id: Ifa3068e2d27713b452c4bcab6a611e3c9b511868
11 files changed
tree: 07fb705722c2a631659a10f2d3a04f94de65654e
  1. src/
  2. .gitignore
  3. BUILD
  4. external_plugin_deps.bzl
  5. Jenkinsfile
  7. README.md

Persistent cache for Gerrit, based on ChronicleMap

Non-blocking and super-fast on-disk cache libModule for Gerrit Code Review based on ChronicleMap on-disk implementation.

How to build

This libModule is built like a Gerrit in-tree plugin, using Bazelisk. See the build instructions for more details.


  • Install cache-chronicalmap module

Install the chronicle-map module into the $GERRIT_SITE/lib directory.

Add the cache-chroniclemap module to $GERRIT_SITE/etc/gerrit.config as follows:

  installModule = com.googlesource.gerrit.modules.cache.chroniclemap.ChronicleMapCacheModule

For further information and supported options, refer to config documentation.

Migration from H2 caches

You can check how to migrate from H2 to chronicle-map here.