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

Fix quadratic complexity in SnapshotStatus serialization #90795

Conversation

original-brownbear
Copy link
Member

The loop here is obviously O(N^2) and it shows as taking multiple seconds to build the by-index map in x-content serialization for a 25k shards snapshot.
This makes the logic O(N) and fixes some potential issues with consistency around concurrent access by using a more appropriate access pattern to the field caching the by-index map.

Still not great but good enough with this change.

relates #77466

The loop here is obviously O(N^2) and it shows as taking multiple
seconds to build the by-index map in x-content serialization for
a 25k shards snapshot.
This makes the logic O(N) and fixes some potential issues with
consistency around concurrent access by using a more appropriate
access pattern to the field caching the by-index map.
@original-brownbear original-brownbear added >bug :Distributed Coordination/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs v8.6.0 labels Oct 11, 2022
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-distributed (Team:Distributed)

@elasticsearchmachine elasticsearchmachine added the Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. label Oct 11, 2022
@elasticsearchmachine
Copy link
Collaborator

Hi @original-brownbear, I've created a changelog YAML for you.

@original-brownbear
Copy link
Member Author

@henningandersen I extracted this from an incoming PR that moves the API to chunked encoding. I made this a separate PR because I wonder if we should backport this to 8.5.x and 7.x, given how this API is causing issues here and there for Cloud ops?

Copy link
Contributor

@henningandersen henningandersen left a comment

Choose a reason for hiding this comment

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

LGTM.

If you have seen this cause issues I think it would be fine to backport to both the releases.

@original-brownbear
Copy link
Member Author

Thanks both!

@elasticsearchmachine
Copy link
Collaborator

💚 Backport successful

Status Branch Result
7.17
8.5

original-brownbear added a commit to original-brownbear/elasticsearch that referenced this pull request Oct 11, 2022
The loop here is obviously O(N^2) and it shows as taking multiple
seconds to build the by-index map in x-content serialization for
a 25k shards snapshot.
This makes the logic O(N) and fixes some potential issues with
consistency around concurrent access by using a more appropriate
access pattern to the field caching the by-index map.
original-brownbear added a commit to original-brownbear/elasticsearch that referenced this pull request Oct 11, 2022
The loop here is obviously O(N^2) and it shows as taking multiple
seconds to build the by-index map in x-content serialization for
a 25k shards snapshot.
This makes the logic O(N) and fixes some potential issues with
consistency around concurrent access by using a more appropriate
access pattern to the field caching the by-index map.
elasticsearchmachine pushed a commit that referenced this pull request Oct 11, 2022
…0803)

The loop here is obviously O(N^2) and it shows as taking multiple
seconds to build the by-index map in x-content serialization for
a 25k shards snapshot.
This makes the logic O(N) and fixes some potential issues with
consistency around concurrent access by using a more appropriate
access pattern to the field caching the by-index map.
@csoulios csoulios added v8.5.0 and removed v8.5.1 labels Nov 8, 2022
elasticsearchmachine pushed a commit that referenced this pull request Jan 3, 2023
…) (#90802)

* Fix quadratic complexity in SnapshotStatus serialization (#90795)

The loop here is obviously O(N^2) and it shows as taking multiple
seconds to build the by-index map in x-content serialization for
a 25k shards snapshot.
This makes the logic O(N) and fixes some potential issues with
consistency around concurrent access by using a more appropriate
access pattern to the field caching the by-index map.

* fix compile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Distributed Coordination/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. v7.17.7 v8.5.0 v8.6.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants