Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Short-circuit single slice searches in ContextIndexSearcher #111126

Conversation

original-brownbear
Copy link
Member

Even with the recent Lucene improvements in
apache/lucene#13472 there is no need to go through all the Lucene machinery for a single slice here. The task executor allocates a bunch of objects and runs into some memory barriers that the JVM can't necessarily compile away. Let's save that overhead for the single slice case and get some of that Lucene 9.12.0 fork-saving behaviour right away. (I am aware this changes the load distribution across search and search_worker a little, but I think it's irrelevant practically because forking and joining a task will probably as expensive as executing it outright in a lot of cases anyway)

Also this PR removes the pointless list of collectors that we were building.
Lastly, a neat side-effect of this change is that it makes whether or not forking has happened a little easier to spot in profiling in the current ES version.

Even with the recent Lucene improvements in
apache/lucene#13472 there is no need
to go through all the Lucene machinery for a single slice here.
The task executor allocates a bunch of objects and runs into some memory
barriers that the JVM can't necessarily compile away.
Lets save that overhead for the single slice case.
Also this PR removes the pointless list of collectors that we were
building.
@original-brownbear original-brownbear added >non-issue :Search/Search Search-related issues that do not fall into other categories labels Jul 20, 2024
@elasticsearchmachine elasticsearchmachine added v8.16.0 Team:Search Meta label for search team labels Jul 20, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search (Team:Search)

@benwtrent benwtrent added :Search Foundations/Search Catch all for Search Foundations and removed :Search/Search Search-related issues that do not fall into other categories labels Jul 22, 2024
@elasticsearchmachine elasticsearchmachine added Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch and removed Team:Search Meta label for search team labels Jul 22, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search-foundations (Team:Search Foundations)

Copy link
Member

@javanna javanna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should make this type of changes. If we see value in these optimizations, we should make improvements in Lucene directly. We already have too much custom search logic in ContextIndexSearcher, that I wish we would look into removing as opposed to making more complex over time.

@original-brownbear
Copy link
Member Author

Fair point, this can actually go into Lucene for a small win. Easier to benchmark there as well :) incoming!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>non-issue :Search Foundations/Search Catch all for Search Foundations Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants