Skip to content

Cheaper handling of skipped shard iterators in AbstractSearchAsyncAction #124223

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

Merged

Conversation

original-brownbear
Copy link
Member

@original-brownbear original-brownbear commented Mar 6, 2025

No reason to blow up the size of AbstractSearchAsyncAction (and the code size of some methods that really only need the size of that collection) needlessly. Just keep the count, that's all we need.
We can build the skipped shard list inline if need be (and do so in a cheaper way because we can build the search targets.

@elasticsearchmachine elasticsearchmachine added the Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch label Mar 6, 2025
@elasticsearchmachine
Copy link
Collaborator

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

this.shardsIts = iterators;
outstandingShards = new AtomicInteger(shardsIts.size());
outstandingShards = new AtomicInteger(shardsIts.size() - skipped);
Copy link
Contributor

Choose a reason for hiding this comment

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

Here it's slightly confusing which shardsIts it is - the parameter shardsIts as I see contains the skipped ones, but this.shardsIts does not. Maybe use a different name for the parameter? Also, isn't it iterators.size()?

Copy link
Contributor

Choose a reason for hiding this comment

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

To think about it, do we really need iterators at all - can't we just work on this.shardsIts directly?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's just a little faster to have a dedicated local variable instead of looking up the field repeatedly, that's all :) There's no other reason to have a separate local variable.

But you're right the naming is horrific :O lets fix that in a follow-up but at least use iterators.size() here :) My idea/hope was actually to get rid of this.shardIts, it's somewhat unnecessary in the grand scheme of things :)

@original-brownbear
Copy link
Member Author

Thanks Stas!

@original-brownbear original-brownbear added the auto-backport Automatically create backport pull requests when merged label Mar 6, 2025
@original-brownbear original-brownbear merged commit b02f15d into elastic:main Mar 6, 2025
17 checks passed
@original-brownbear original-brownbear deleted the cheaper-skip-it-logic branch March 6, 2025 22:33
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

Status Branch Result
8.x Commit could not be cherrypicked due to conflicts

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 124223

georgewallace pushed a commit to georgewallace/elasticsearch that referenced this pull request Mar 11, 2025
…ion (elastic#124223)

No reason to blow up the size of `AbstractSearchAsyncAction` (and the code size of some methods that really only need the size of that collection) needlessly. Just keep the count, that's all we need. 
We can build the skipped shard list inline if need be (and do so in a cheaper way because we can build the search targets.
costin pushed a commit to costin/elasticsearch that referenced this pull request Mar 15, 2025
…ion (elastic#124223)

No reason to blow up the size of `AbstractSearchAsyncAction` (and the code size of some methods that really only need the size of that collection) needlessly. Just keep the count, that's all we need. 
We can build the skipped shard list inline if need be (and do so in a cheaper way because we can build the search targets.
original-brownbear added a commit to original-brownbear/elasticsearch that referenced this pull request Apr 9, 2025
…ion (elastic#124223)

No reason to blow up the size of `AbstractSearchAsyncAction` (and the code size of some methods that really only need the size of that collection) needlessly. Just keep the count, that's all we need.
We can build the skipped shard list inline if need be (and do so in a cheaper way because we can build the search targets.
elasticsearchmachine pushed a commit that referenced this pull request Apr 9, 2025
…ion (#124223) (#126533)

No reason to blow up the size of `AbstractSearchAsyncAction` (and the code size of some methods that really only need the size of that collection) needlessly. Just keep the count, that's all we need.
We can build the skipped shard list inline if need be (and do so in a cheaper way because we can build the search targets.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Automatically create backport pull requests when merged >non-issue :Search Foundations/Search Catch all for Search Foundations Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch v8.19.0 v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants