[ 
https://issues.apache.org/jira/browse/OAK-12425?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Rishabh Daim updated OAK-12425:
-------------------------------
    Description: 
Allow DocumentNodeStore caches, including LOCAL_DIFF, to use Caffeine with SYNC 
maintenance behind disabled-by-default FT_CAFFEINE_CACHE_OAK-12425. Standalone 
deployments opt in with {{-Doak.documentMK.caffeineCache=true}}.

Keep the existing NodeCache/CacheMetadata path, raw values, weights and 
persisted format. With the feature off, retain the existing cache selection. 
Register eviction forwarding before attaching the persistent wrapper.

Sample the feature once per builder; applying a change requires recreating the 
builder/store or restarting the service. Test feature selection, eviction, 
persistence and diff behavior in both implementations.

[PR #3176|https://github.com/apache/jackrabbit-oak/pull/3176] depends on 
OAK-12438. Optional ASYNC maintenance and entry metadata belong to OAK-12437; 
benchmarks belong to OAK-12426.


  was:
h3. Summary
Allow oak-store-document to opt into Caffeine with synchronous maintenance 
while preserving the existing CacheLIRS persistent-cache implementation and 
metadata flow.

h3. Scope
Build on OAK-12436 and OAK-12438. Gate Caffeine selection behind 
FT_CAFFEINE_CACHE_OAK-12425, disabled by default. Standalone processes 
explicitly opt in using -Doak.documentMK.caffeineCache=true. Select SYNC 
maintenance for all Document caches. Retain CacheLIRS for positive-weight 
LOCAL_DIFF even when Caffeine is enabled; the zero-weight path keeps its 
existing no-cache behavior. Snapshot implementation selection once per builder 
and require a replacement builder/DocumentNodeStore after a feature change. 
Register the eviction listener before the persistent wrapper attaches its 
callback.

Keep NodeCache, CacheMetadata, raw values, live maps, custom weights, cache 
statistics, the persistent file format and persistent-write behavior unchanged. 
Entry-owned metadata, new mutation monitors and guarded persistence belong 
exclusively to OAK-12437's optional ASYNC path. Add further production fixes 
here only when a test demonstrates a Caffeine SYNC compatibility issue.

h3. Acceptance Criteria
* Default feature-off behavior retains CacheLIRS and the original 
persistent-cache wrapper.
* Feature-on behavior uses Caffeine SYNC except LOCAL_DIFF, which retains 
CacheLIRS admission with the original metadata representation and no new entry 
overhead.
* Implementation selection remains stable across caches constructed by the same 
builder; feature changes require restart/recreation.
* Persistent size evictions reach the existing wrapper, including when the 
listener is attached after memory-cache construction.
* Existing persistence, broadcast, compatibility, loader and raw-value/weight 
tests pass with both CacheLIRS and Caffeine SYNC under Java 17.
* [PR #3176|https://github.com/apache/jackrabbit-oak/pull/3176] contains the 
minimal SYNC migration. Optional ASYNC and entry-owned metadata are in 
[OAK-12437|https://issues.apache.org/jira/browse/OAK-12437] / PR #3190; 
comparative measurements follow in OAK-12426 / PR #3174.

h3. LOCAL_DIFF compatibility
Wide-folder, memory-pressure commit/diff diagnostics reproduce admission misses 
with Caffeine SYNC: large setup diffs can displace freshly published small 
diffs before their first lookup. Disabling periodic background work leaves the 
bulk-load journal pending and greatly amplifies those misses through broad diff 
candidates and node-state reads. The benchmark audit below separates this 
stress setup from default-sized, normally maintained workloads. Keep LOCAL_DIFF 
on the existing LIRS builder, preserving its memory budget, segment settings, 
raw weights, persistence wrapper and eviction callbacks. Test fresh-diff 
retention under real eviction pressure, zero-weight behavior and stable 
implementation selection. [Diagnosis and repeated benchmark 
results|https://github.com/apache/jackrabbit-oak/pull/3174#issuecomment-5886471110].


h3. Benchmark audit and migration goal
The goal remains Caffeine throughout oak-store-document. The LOCAL_DIFF LIRS 
exception is a temporary regression mitigation/control; do not treat the hybrid 
policy as a completed all-Caffeine migration. OAK-12426 measures normal commits 
plus saved-value verification separately from commits with an additional 
explicit parent diff. Use 256 MiB as the primary total repository-cache budget 
with production distribution, and 384 MiB for 50% more memory. Compare the 
hybrid policy against all-Caffeine LOCAL_DIFF controls. Report merge, explicit 
diff and readback time, local-diff memory hits/misses and backend finds. 
Exercise 10,000 and 120,000 total data nodes under the same 256/384 MiB 
budgets. Use a bucket/group hierarchy with 100 data children per group and at 
most 100 groups per bucket by default; total nodes are not siblings. Keep 
folder width configurable. Use the production one-second DocumentNodeStore 
background interval during setup and timing. Label 1,000-child folders and 
disabled-background runs as stress diagnostics. Pending unflushed bulk-load 
journal paths can greatly amplify a local-diff miss; do not attribute the 
entire diagnostic slowdown to cache policy alone. Keep direct NODE 
microbenchmark capacity separate from the repository total-cache budget. Label 
earlier 16/24 MiB results as memory-pressure diagnostics, not typical 
production throughput. EmptyHook and MemoryDocumentStore omit application hooks 
and remote database latency.


OAK-12426 additionally compares all-Caffeine SYNC/ASYNC (including LOCAL_DIFF) 
with CacheLIRS at 16/24 MiB, using the one-second background interval. Repeat 
both the 100-child main hierarchy and 1,000-child wide-folder diagnostic. 
Publish three-run medians, fork variability and measured phase costs in the 
existing benchmark comment. These comparisons evaluate performance; the 
production LOCAL_DIFF exception remains temporary and is not removed by the 
benchmark changes.



> Opt into Caffeine SYNC maintenance in oak-store-document
> --------------------------------------------------------
>
>                 Key: OAK-12425
>                 URL: https://issues.apache.org/jira/browse/OAK-12425
>             Project: Jackrabbit Oak
>          Issue Type: Technical task
>            Reporter: Rishabh Daim
>            Assignee: Rishabh Daim
>            Priority: Major
>
> Allow DocumentNodeStore caches, including LOCAL_DIFF, to use Caffeine with 
> SYNC maintenance behind disabled-by-default FT_CAFFEINE_CACHE_OAK-12425. 
> Standalone deployments opt in with {{-Doak.documentMK.caffeineCache=true}}.
> Keep the existing NodeCache/CacheMetadata path, raw values, weights and 
> persisted format. With the feature off, retain the existing cache selection. 
> Register eviction forwarding before attaching the persistent wrapper.
> Sample the feature once per builder; applying a change requires recreating 
> the builder/store or restarting the service. Test feature selection, 
> eviction, persistence and diff behavior in both implementations.
> [PR #3176|https://github.com/apache/jackrabbit-oak/pull/3176] depends on 
> OAK-12438. Optional ASYNC maintenance and entry metadata belong to OAK-12437; 
> benchmarks belong to OAK-12426.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to