lweitzendorf opened a new pull request, #3207:
URL: https://github.com/apache/jackrabbit-oak/pull/3207

   https://issues.apache.org/jira/browse/OAK-12452
   
   ## Summary
   Reduces allocation and contention in the segment `ReaderCache` (used by 
`StringCache` and `TemplateCache`). The PR has four commits that can be 
reviewed one at a time:
   
   1. **Promote to the fast tier only after reuse.** `get()` used to allocate a 
`FastCacheEntry` on every fast-tier miss, including first-time loads. 
Compaction's sequential scan reads most keys exactly once, so this produced 
many single-use allocations. Entries are now promoted only on a slow-tier hit.
   2. **Skip the slow tier when its weight is 0.** Previously every fast-tier 
miss still created a key, probed, inserted and immediately evicted from the 
slow tier.
   3. **Build the slow tier with the Caffeine-backed Oak `CacheBuilder` instead 
of `CacheLIRS`**, as was done for `SegmentCache` and `RecordCache` in 
OAK-12157. `CacheLIRS` and its other uses are unchanged apart from two 
diamond-operator cleanups. Also drops the unused `averageWeight` constructor 
parameter.
   4. **Cleanup:** `CacheKey` and `FastCacheEntry` become records, the cached 
hash fields are removed, and `FastCache` computes its own index.
   
   ## Benchmarks (JMH 1.37, JDK 23, `-prof gc`)
   | change | before | after |
   |---|---|---|
   | 1. read-once access pattern | 112 B/op, ~124 ns/op | 72 B/op, ~109 ns/op |
   | 2. weight 0, fast-tier miss, 48 threads | 24.3 ops/µs, 171.6 B/op | 178.3 
ops/µs, 110.4 B/op |
   
   For change 3, end-to-end throughput in a 48-thread read-heavy workload was 
at parity with `CacheLIRS`.
   
   There is no feature toggle, following the precedent of the `SegmentCache` 
migration. Happy to add one for changes 1 and 2 if reviewers prefer.
   
   ## Tests
   `ReaderCacheTest` is updated: its LIRS-specific hit-rate assertion is now 
implementation-neutral, `largeEntries` is replaced by 
`fastOnlyLargeValueReDecoded` (weight-0 path) and 
`largeEntryServedFromSlowCache`. Existing tests cover the deferred promotion.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to