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

Switch ContextIndexSearcher to use Lucene's TaskExecutor #101537

Merged

Conversation

javanna
Copy link
Member

@javanna javanna commented Oct 30, 2023

We have contributed back to Lucene the changes we had made around running
concurrent tasks. These include waiting for all tasks to finish when an
exception is thrown, as well as not starting tasks when one of the
previously run tasks throws an exception.

The execution of concurrent tasks is now generalized within Lucene and
exposed through a TaskExecutor that can be retrieved from the
IndexSearcher and used to run tasks. We still have customizations that
require us to override some of the search method, but with this change
we rely on standard Lucene's behaviour for running concurrent tasks.

We have contributed back to Lucene the changes we had made around running
concurrent tasks. These include waiting for all tasks to finish when an
exception is thrown, as well as not starting tasks when one of the
previously run tasks throws an exception.

The execution of concurrent tasks is now generalized within Lucene and
exposed through a TaskExecutor that can be retrieved from the
IndexSearcher and used to run tasks. We still have customizations that
require us to override some of the search method, but with this change
we rely on standard Lucene's behaviour for running concurrent tasks.
@javanna javanna added :Search/Search Search-related issues that do not fall into other categories >refactoring v8.12.0 labels Oct 30, 2023
@elasticsearchmachine elasticsearchmachine added the Team:Search Meta label for search team label Oct 30, 2023
@elasticsearchmachine
Copy link
Collaborator

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

search(Arrays.asList(leaves), weight, collector);
if (timeExceeded) {
for (Future<?> future : listTasks) {
FutureUtils.cancel(future);
Copy link
Member Author

Choose a reason for hiding this comment

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

we used to have cancellation on timeout as well. This is not currently implemented in Lucene (we cancel only on exceptions), and looking further at implementing that, I realized that it's perhaps not needed, because if one task times out, it is expected that others will do too, as the timeout impl is shared across the different tasks. That is even better, as it will make running tasks stop too, which is something that tasks cancellation does not support yet.

Copy link
Contributor

@romseygeek romseygeek left a comment

Choose a reason for hiding this comment

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

LGTM! Lots of lovely line deletions...

@javanna javanna merged commit e9776b2 into elastic:lucene_snapshot Oct 31, 2023
12 checks passed
@javanna javanna deleted the enhancement/search_task_executor branch October 31, 2023 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>refactoring :Search/Search Search-related issues that do not fall into other categories Team:Search Meta label for search team v8.12.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants