You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "dnhatn (via GitHub)" <gi...@apache.org> on 2026/02/19 00:35:09 UTC
[PR] Add hook for LRUQueryCache to allow custom population strategies [lucene]
dnhatn opened a new pull request, #15723:
URL: https://github.com/apache/lucene/pull/15723
In Elasticsearch, we execute intra-segment searches across multiple threads, which can trigger redundant, concurrent cache populations for the same segment. Since each slice-search targets a subset of the segment but cache population scans the entire segment, this amplification significantly wastes I/O and CPU for expensive queries. This PR introduces a hook in LRUQueryCache to allow custom population strategies, such as delegating to a background thread or skipping redundant populations. There is no change to the default behavior of LRUQueryCache.
--
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] Add hook for LRUQueryCache to allow custom population strategies [lucene]
Posted by "dnhatn (via GitHub)" <gi...@apache.org>.
dnhatn merged PR #15723:
URL: https://github.com/apache/lucene/pull/15723
--
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] Add hook for LRUQueryCache to allow custom population strategies [lucene]
Posted by "dnhatn (via GitHub)" <gi...@apache.org>.
dnhatn commented on PR #15723:
URL: https://github.com/apache/lucene/pull/15723#issuecomment-3929179449
@martijnvg @romseygeek Thank you!
--
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] Add hook for LRUQueryCache to allow custom population strategies [lucene]
Posted by "dnhatn (via GitHub)" <gi...@apache.org>.
dnhatn commented on code in PR #15723:
URL: https://github.com/apache/lucene/pull/15723#discussion_r2829464669
##########
lucene/core/src/test/org/apache/lucene/search/TestLRUQueryCache.java:
##########
@@ -1603,6 +1608,194 @@ public void testReaderNotSuitedForCaching() throws IOException {
dir.close();
}
+ public void testSkipCacheIfOngoing() throws Exception {
+ Directory dir = newDirectory();
+ IndexWriterConfig iwc = new IndexWriterConfig();
+ IndexWriter w = new IndexWriter(dir, iwc);
+ int numThreads = RandomNumbers.randomIntBetween(random(), 2, 6);
+ int numDocs = numThreads * 100;
+ for (int i = 0; i < numDocs; i++) {
+ var doc = new Document();
+ doc.add(new StringField("doc", Integer.toString(i), Store.NO));
+ w.addDocument(doc);
+ }
+ DirectoryReader reader = DirectoryReader.open(w);
+ assertThat(reader.leaves(), hasSize(1));
+ LeafReaderContext singleLeaf = reader.leaves().get(0);
+
+ AtomicInteger visited = new AtomicInteger(0);
Review Comment:
++ added in https://github.com/apache/lucene/pull/15723/commits/4f80ab0108c5ed396ffcd2c615c210a79cd8b1b0
--
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] Add hook for LRUQueryCache to allow custom population strategies [lucene]
Posted by "romseygeek (via GitHub)" <gi...@apache.org>.
romseygeek commented on code in PR #15723:
URL: https://github.com/apache/lucene/pull/15723#discussion_r2826475462
##########
lucene/core/src/test/org/apache/lucene/search/TestLRUQueryCache.java:
##########
@@ -1603,6 +1608,194 @@ public void testReaderNotSuitedForCaching() throws IOException {
dir.close();
}
+ public void testSkipCacheIfOngoing() throws Exception {
+ Directory dir = newDirectory();
+ IndexWriterConfig iwc = new IndexWriterConfig();
+ IndexWriter w = new IndexWriter(dir, iwc);
+ int numThreads = RandomNumbers.randomIntBetween(random(), 2, 6);
+ int numDocs = numThreads * 100;
+ for (int i = 0; i < numDocs; i++) {
+ var doc = new Document();
+ doc.add(new StringField("doc", Integer.toString(i), Store.NO));
+ w.addDocument(doc);
+ }
+ DirectoryReader reader = DirectoryReader.open(w);
+ assertThat(reader.leaves(), hasSize(1));
+ LeafReaderContext singleLeaf = reader.leaves().get(0);
+
+ AtomicInteger visited = new AtomicInteger(0);
Review Comment:
It took me a while to work out what this test was actually doing (dividing up the document space into numThreads sections, and searching each section separately in its own thread) - maybe add some comments to make it a bit clearer?
--
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