prudhvigodithi commented on PR #16306:
URL: https://github.com/apache/lucene/pull/16306#issuecomment-7118566340

   @sgup432 since you're working on the `LRUQueryCache` side 
https://github.com/apache/lucene/pull/17056, I'm looking at the other half of 
the same path: the caching policy that decides what gets cached.
   
    On every search, `LRUQueryCache` calls into 
`UsageTrackingQueryCachingPolicy` twice:
     1. `onUse(Q)` records the use of the query.
     2. On a cache miss, `shouldCache(Q)` decides whether Q has been used often 
enough to cache.
     
   Today both calls go through one `synchronized` block around a single 
256-slot `FrequencyTrackingRingBuffer` and its `IntBag` of counts
   
   This PR splits the usage history:
     - 16 small ring buffers of 16 slots each, with a query always mapping to 
the same one.
     - `onUse` writes under that buffer's own lock only, with no count table to 
update.
     - `shouldCache` counts by scanning the 16 slots without taking a lock.
   
    Results:
   - JMH: `onUse` about 2.4× and `shouldCache` about 1.6× faster 
single-threaded, and 2–5× faster under contention as shown in PR description


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to