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.    **After fix**  <!-- 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