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

Rishabh Daim updated OAK-12437:
-------------------------------
    Description: 
Add optional per-cache ASYNC maintenance to DocumentNodeStore, including 
LOCAL_DIFF, on top of OAK-12425. Require the Caffeine opt-in, 
disabled-by-default FT_OAK-12437 and an explicit ASYNC request for each cache.

Persistent ASYNC caches store metadata with each entry and guard delayed 
eviction writes against replacement and invalidation. Non-persistent caches 
keep raw values and weights; persisted values remain compatible.

With the ASYNC feature off, use the parent SYNC wrapper and metadata path 
without ASYNC overhead. Unconfigured caches remain SYNC. Feature changes 
require recreating the builder/store or restarting the service.

Test both feature gates, modes, persistence, zero capacity, raw map operations, 
delayed callbacks and reopen behavior.

[PR #3190|https://github.com/apache/jackrabbit-oak/pull/3190] depends on [PR 
#3176|https://github.com/apache/jackrabbit-oak/pull/3176]. OAK-12426 benchmarks 
both paths.


  was:
h3. Summary
Add optional per-cache asynchronous Caffeine maintenance together with 
entry-owned persistent-cache metadata. Gate the complete ASYNC implementation 
behind disabled-by-default FT_OAK-12437.

h3. Scope
Build on OAK-12425's minimal FT-gated Caffeine SYNC migration. Caffeine must 
also be enabled. When FT_OAK-12437 is off, even explicit ASYNC requests use the 
exact OAK-12425 SYNC cache/wrapper/metadata path. When enabled, only explicitly 
selected eligible CacheTypes use ASYNC; unconfigured caches and LOCAL_DIFF 
remain SYNC. LOCAL_DIFF retains the parent LIRS/original-metadata path, even 
when ASYNC is explicitly requested. Standalone ASYNC requires both 
-Doak.documentMK.caffeineCache=true and 
-Doak.documentMK.asyncCacheMaintenance=true.

Only persistent caches actually selected as ASYNC use entry-owned access count, 
persistence-origin, retirement and invalidation-generation metadata, live 
raw-value adapters, per-key mutation coordination and guarded persistence 
writes. Preserve the original NodeCache and CacheMetadata for SYNC and 
CacheLIRS. FT-off operation must not add ASYNC entry overhead or use the new 
wrapper and guarded-write protocol. Keep the persisted value format unchanged.

A builder snapshots feature selection once. Existing caches retain their 
implementation and mode. Recreate the builder and DocumentNodeStore after 
changing either feature; preserve desired toggle state across service 
stop/start. Segment Tar remains independent.

h3. Acceptance Criteria
* Default FT-off behavior is the parent SYNC behavior, including wrapper 
identity, raw map behavior and exact custom weights.
* ASYNC requires the Caffeine FT, the ASYNC FT and explicit per-cache selection 
together.
* Caffeine-off ASYNC requests retain CacheLIRS and resolve to SYNC.
* Entry metadata follows the exact cache entry; delayed callbacks cannot 
consume replacement metadata or persist invalidated/stale entries.
* Async-only loading and guarded-write changes cannot affect the legacy/SYNC 
path.
* Tests cover all feature/mode combinations, toggle transitions/restart, actual 
callback threads, production persistent caches, raw map mutations and delayed 
persistence ordering. Existing legacy persistence tests continue passing 
unchanged.
* [PR #3190|https://github.com/apache/jackrabbit-oak/pull/3190] directly 
depends on [PR #3176|https://github.com/apache/jackrabbit-oak/pull/3176]. 
OAK-12426 / PR #3174 compares the legacy-metadata SYNC path against the 
entry-metadata ASYNC path and must rerun measurements after this rescope.

* LOCAL_DIFF always resolves to SYNC and uses original NodeCache 
metadata/weights with persistence enabled. Positive-weight LOCAL_DIFF retains 
LIRS; zero-weight LOCAL_DIFF keeps the existing no-cache path. Test both 
features, persistence on/off, zero/nonzero budgets and inline callbacks while 
other caches still honor ASYNC opt-in.


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 Document Caffeine ASYNC maintenance with entry-owned metadata
> ----------------------------------------------------------------------
>
>                 Key: OAK-12437
>                 URL: https://issues.apache.org/jira/browse/OAK-12437
>             Project: Jackrabbit Oak
>          Issue Type: Task
>            Reporter: Rishabh Daim
>            Priority: Major
>
> Add optional per-cache ASYNC maintenance to DocumentNodeStore, including 
> LOCAL_DIFF, on top of OAK-12425. Require the Caffeine opt-in, 
> disabled-by-default FT_OAK-12437 and an explicit ASYNC request for each cache.
> Persistent ASYNC caches store metadata with each entry and guard delayed 
> eviction writes against replacement and invalidation. Non-persistent caches 
> keep raw values and weights; persisted values remain compatible.
> With the ASYNC feature off, use the parent SYNC wrapper and metadata path 
> without ASYNC overhead. Unconfigured caches remain SYNC. Feature changes 
> require recreating the builder/store or restarting the service.
> Test both feature gates, modes, persistence, zero capacity, raw map 
> operations, delayed callbacks and reopen behavior.
> [PR #3190|https://github.com/apache/jackrabbit-oak/pull/3190] depends on [PR 
> #3176|https://github.com/apache/jackrabbit-oak/pull/3176]. OAK-12426 
> benchmarks both paths.



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

Reply via email to