Lucas Weitzendorf created OAK-12452:
---------------------------------------

             Summary: Reduce allocation and contention in the segment 
ReaderCache
                 Key: OAK-12452
                 URL: https://issues.apache.org/jira/browse/OAK-12452
             Project: Jackrabbit Oak
          Issue Type: Improvement
          Components: segment-tar
            Reporter: Lucas Weitzendorf


{{ReaderCache}} (used by {{StringCache}} and {{TemplateCache}}) has a lock-free 
fast tier in front of a {{CacheLIRS}} slow tier. Proposed changes, in order:
# *Promote to the fast tier only after reuse.* Today {{get()}} allocates a 
{{FastCacheEntry}} on every fast-tier miss, including first-time loads. 
Compaction's sequential scan reads most keys exactly once, so this produces 
large numbers of single-use allocations. Entries should be promoted only on a 
slow-tier hit. JMH on a read-once pattern: 112 -> 72 B/op, throughput about the 
same.
# *Skip the slow tier when its weight is 0.* At weight 0, every fast-tier miss 
still creates a key, looks it up, inserts it into the LIRS cache, and evicts it 
immediately. Bypassing the slow tier: at 48 threads, 24.3 -> 178.3 ops/us and 
171.6 -> 110.4 B/op.
# *Build the slow tier with the Caffeine-backed Oak {{CacheBuilder}} instead of 
{{CacheLIRS}}.* {{CacheLIRS}} itself and its other uses are unchanged. This 
also removes the unused {{averageWeight}} constructor parameter.
# *Cleanup:* make {{CacheKey}} and {{FastCacheEntry}} records, drop the cached 
hash fields, and have {{FastCache}} compute its own index.



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

Reply via email to