Nuno Santos created OAK-12416:
---------------------------------
Summary: Avoid per-write CacheAccessTracker/CounterStats
allocation overhead
Key: OAK-12416
URL: https://issues.apache.org/jira/browse/OAK-12416
Project: Jackrabbit Oak
Issue Type: Improvement
Reporter: Nuno Santos
{{WriterCacheManager.AccessTrackingCacheManager#getStringCache}}/{{getTemplateCache}}/{{getNodeCache}}
are invoked once per record written. Each call currently re-registers the
corresponding {{CounterStats}} via {{StatisticsProvider#getCounterStats}} and
allocates a new {{CacheAccessTracker}} wrapper, which does a map lookup/insert
in the statistics registry on every write.
Register the six {{CounterStats}} (access/miss count per cache kind) once in
the {{AccessTrackingCacheManager}} constructor, and add a
{{CacheAccessTracker}} constructor that accepts already-registered
{{CounterStats}} directly, so the per-write path only allocates the lightweight
wrapper. Keep the existing {{CacheAccessTracker(String, StatisticsProvider,
Cache)}} constructor for compatibility, deprecated in favor of the new one.
No functional/API change: the wrapper cache is still resolved from the delegate
on every call (not memoized), so cache generation eviction/recreation semantics
are preserved; only the statistics registration is hoisted out of the hot path.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)