Repository navigation
Add hook for LRUQueryCache to allow custom population strategies - #15723
Merged
Merged
Conversation
dnhatn
marked this pull request as ready for review
February 19, 2026 01:05
romseygeek
approved these changes
Feb 19, 2026
| assertThat(reader.leaves(), hasSize(1)); | ||
| LeafReaderContext singleLeaf = reader.leaves().get(0); | ||
|
|
||
| AtomicInteger visited = new AtomicInteger(0); |
Contributor
There was a problem hiding this 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?
Member
Author
|
@martijnvg @romseygeek Thank you! |
dnhatn
added a commit
that referenced
this pull request
Feb 19, 2026
) 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.
dnhatn
added a commit
that referenced
this pull request
Feb 19, 2026
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. Backport of #15723 to 10.x
gmarouli
pushed a commit
to gmarouli/lucene
that referenced
this pull request
Feb 20, 2026
…che#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.
dnhatn
added a commit
to elastic/elasticsearch
that referenced
this pull request
Feb 20, 2026
This change forks LRUQueryCache to include apache/lucene#15723 so that we can override cache population behavior for intra-segment searches. With ES|QL doc_partitioning, each thread can independently populates the query cache for the same segment. The actual changes will be in a follow-up PR. Once Lucene 10.5 or 11 is released, we should remove this fork.
PeteGillinElastic
pushed a commit
to PeteGillinElastic/elasticsearch
that referenced
this pull request
Feb 23, 2026
This change forks LRUQueryCache to include apache/lucene#15723 so that we can override cache population behavior for intra-segment searches. With ES|QL doc_partitioning, each thread can independently populates the query cache for the same segment. The actual changes will be in a follow-up PR. Once Lucene 10.5 or 11 is released, we should remove this fork.
jimczi
added a commit
to elastic/elasticsearch
that referenced
this pull request
Jun 29, 2026
The fork existed only to backport apache/lucene#15723 (the tryPopulateCache hook for intra-segment cache population). Lucene 10.5 ships that hook, so ElasticsearchLRUQueryCache extends the upstream LRUQueryCache directly and the fork is deleted.
jimczi
added a commit
to elastic/elasticsearch
that referenced
this pull request
Jun 29, 2026
Adds coverage for the intra-segment cache gate doc-partitioning relies on: a query whose weight is an OptionalCachingWeight populates the cache only when startCaching grants the claim, and falls back to an uncached scorer otherwise. Guards the seam now served by Lucene 10.5 (apache/lucene#15723).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.