You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "gtroitskiy (via GitHub)" <gi...@apache.org> on 2023/10/03 01:38:34 UTC
[PR] Make QueryCache respect Accountable queries on eviction and consisten… [lucene]
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-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Make QueryCache respect Accountable queries on eviction and consisten… [lucene]
Posted by "gtroitskiy (via GitHub)" <gi...@apache.org>.
gtroitskiy commented on PR #12614:
URL: https://github.com/apache/lucene/pull/12614#issuecomment-1744720246
Thanks for reviewing! I ran tidy and made some refactoring
--
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-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Make LRUQueryCache respect Accountable queries on eviction and consisten… [lucene]
Posted by "jaebongim (via GitHub)" <gi...@apache.org>.
jaebongim commented on PR #12614:
URL: https://github.com/apache/lucene/pull/12614#issuecomment-2222013014
@gtroitskiy @romseygeek
Is the bug fixed on 8.12 Elasticseach?
--
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-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Make QueryCache respect Accountable queries on eviction and consisten… [lucene]
Posted by "romseygeek (via GitHub)" <gi...@apache.org>.
romseygeek commented on PR #12614:
URL: https://github.com/apache/lucene/pull/12614#issuecomment-1744588907
Can you run `./gradlew tidy` at the root of the project to make sure the formatting is all correct?
--
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-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Make LRUQueryCache respect Accountable queries on eviction and consisten… [lucene]
Posted by "justinmarygopal (via GitHub)" <gi...@apache.org>.
justinmarygopal commented on PR #12614:
URL: https://github.com/apache/lucene/pull/12614#issuecomment-2095502552
I am also facing the same issue after the upgrade of elastic to 8.10 from 8.7.
Then we upgraded to 8.12, still we are seeing a similar behaviour . Any suggestions please?
--
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-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Make LRUQueryCache respect Accountable queries on eviction and consisten… [lucene]
Posted by "romseygeek (via GitHub)" <gi...@apache.org>.
romseygeek merged PR #12614:
URL: https://github.com/apache/lucene/pull/12614
--
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-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Make QueryCache respect Accountable queries on eviction and consisten… [lucene]
Posted by "romseygeek (via GitHub)" <gi...@apache.org>.
romseygeek commented on code in PR #12614:
URL: https://github.com/apache/lucene/pull/12614#discussion_r1343791876
##########
lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java:
##########
@@ -385,7 +385,9 @@ public void clearQuery(Query query) {
private void onEviction(Query singleton) {
assert lock.isHeldByCurrentThread();
- onQueryEviction(singleton, LINKED_HASHTABLE_RAM_BYTES_PER_ENTRY + QUERY_DEFAULT_RAM_BYTES_USED);
+ var ramBytesUsedByQuery = LINKED_HASHTABLE_RAM_BYTES_PER_ENTRY;
+ ramBytesUsedByQuery += singleton instanceof Accountable accountableQuery ? accountableQuery.ramBytesUsed() : QUERY_DEFAULT_RAM_BYTES_USED;
Review Comment:
Can we pull this out into a separate `queryRamBytesUsed(Query q)` method, given that it's used twice?
--
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-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org