gtroitskiy opened a new pull request, #12614:
URL: https://github.com/apache/lucene/pull/12614

   …cy check
   
   **Root cause**
   `onQueryCache` increases `ramBytesUsed` for specified amount, that is being 
calculated with respect to query being `Accountable` or not.
   Unfortunately, `onQueryEviction` does not the same. If some heavy 
accountable query has `ramBytesUsed()` greater than 
`QUERY_DEFAULT_RAM_BYTES_USED`, the delta `ghostBytes = ramBytesUsed() - 
QUERY_DEFAULT_RAM_BYTES_USED` remains in total `LRUQueryCache#ramBytesUsed` 
forever.
   
   **Hit rate drops to 0**
   since total sum of ghost bytes monotonously increases with each cached 
accountable query (>QUERY_DEFAULT_RAM_BYTES_USED), eventually it becomes 
greater than `maxRamBytesUsed`, and each newly cached query immediately evicts 
from the cache.
   
   **Current behavior of LRUQueryCache for some real service in production 
[though not fully optimized]**
   1. Service restarted.
   2. Reached `maxRamBytesUsed`. Started eviction. From now on size of cached 
queries decreases to compensate increasing ghost bytes.
   3. Total amount of ghost bytes is greater than `maxRamBytesUsed`. If any new 
query was cached, it evicted at the same time. Cache size is 0. Hit rate is 0. 
   
![ram](https://github.com/apache/lucene/assets/1190066/804b0514-8fa8-4749-bf64-853d07225785)
   
![size2](https://github.com/apache/lucene/assets/1190066/6d1ee142-b780-4c73-a787-9460a5c9ab9c)
   
![hitrate](https://github.com/apache/lucene/assets/1190066/bf328c17-4fe7-4b25-a94a-4cd473d4edff)
   
   **After fix**
   
![Selection_693](https://github.com/apache/lucene/assets/1190066/1b330825-c62f-4b4e-80ce-107675303379)
   
   <!--
   If this is your first contribution to Lucene, please make sure you have 
reviewed the contribution guide.
   https://github.com/apache/lucene/blob/main/CONTRIBUTING.md
   -->
   


-- 
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: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to