Skip to content

Make AllocationService#adaptAutoExpandReplicas Faster #83092

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

Conversation

original-brownbear
Copy link
Contributor

@original-brownbear original-brownbear commented Jan 25, 2022

This method is getting fairly expensive for large cluster states.
In most cases it is not necessary to actually compute the RoutingAllocation
so I made that lazy to save potentially needlessly building routing nodes.
Also, parsing the auto-expand-replicas setting gets quite expensive when looping
over thousands of shards in this method so I moved the auto-expand setting value
into the index metadata.
These changes make the method disappear from profiling in most cases and help
make reroute yet a bit faster.

relates #77466

This method is getting fairly expensive for large cluster states.
In most cases it is not necessary to actually compute the `RoutingAllocation`
so I made that lazy to save potentially needlessly building routing nodes.
Also, parsing the auto-expand-replicas setting gets quite expensive when looping
over thousands of shards in this method so I moved the auto-expand setting value
into the index metadata.
These changes make the method disappear from profiling in most cases and help
make reroute yet a bit faster.
@original-brownbear original-brownbear added >enhancement :Distributed Coordination/Allocation All issues relating to the decision making around placing a shard (both master logic & on the nodes) v8.1.0 labels Jan 25, 2022
@elasticmachine elasticmachine added the Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. label Jan 25, 2022
@elasticmachine
Copy link
Collaborator

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

@elasticsearchmachine
Copy link
Collaborator

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

@@ -42,15 +43,10 @@

private final AllocationDeciders deciders;

@Nullable
private final RoutingNodes routingNodes;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't need to generate this when constructing the object. In some cases the routing nodes are never needed for the concrete cluster state passed in here because none of the allocators care about it. So we can selectively make it lazy like this and pass in the mutable variant as an override.

Copy link
Contributor

@DaveCTurner DaveCTurner left a comment

Choose a reason for hiding this comment

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

LGTM

@original-brownbear
Copy link
Contributor Author

Thanks David!

@original-brownbear original-brownbear merged commit 788df35 into elastic:master Jan 26, 2022
@original-brownbear original-brownbear deleted the faster-auto-expand-replicas branch January 26, 2022 11:07
@original-brownbear original-brownbear restored the faster-auto-expand-replicas branch April 18, 2023 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed Coordination/Allocation All issues relating to the decision making around placing a shard (both master logic & on the nodes) >enhancement Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. v8.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants