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

Use fast path for 0 or 1-segment searches #113969

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

original-brownbear
Copy link
Member

Partly motivated by the desire to have a clearly identifiable code path for non-concurrent search execution in profiling, but does save a couple of cycles and an equivalent fix in Lucene (I'll open a PR as well) yields a measurable speedup.

We can short-circuit both the 0 and and 1-segment use cases. For zero segments, we can skip rewrite and weight creation, for a single segment we can fully bypass the TaskExecutor overhead and save a couple of memory barriers.

Also, we can save building the intermediary Collector list and simply create the tasks right away.

We can short-circuit both the 0 and and 1-segment use cases.
For zero segments, we can skip rewrite and weight cration, for a single
segment we can fully bypass the `TaskExcecutor` overhead and save
a couple of memory barriers.
@original-brownbear original-brownbear added >non-issue :Search Foundations/Search Catch all for Search Foundations labels Oct 2, 2024
@elasticsearchmachine elasticsearchmachine added v9.0.0 Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch labels Oct 2, 2024
@elasticsearchmachine
Copy link
Collaborator

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


@Override
public Query rewrite(IndexSearcher indexSearcher) throws IOException {
maybeThrow(context);
Copy link
Member Author

Choose a reason for hiding this comment

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

Had to adjust this since some tests without data started failing on account that we weren't creating the weight any longer.

@javanna
Copy link
Member

javanna commented Oct 2, 2024

We discussed a similar change in #111126 , I am not convinced this is the way to go. I'd like to better understand the motivations. To be clear, I don't like that these methods that we override from plain Lucene diverge that much from their original implementation. These to me are forks that we should strive to remove over time, as opposed to optimizing them.

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 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants