Skip to content

Make AllocationService#adaptAutoExpandReplicas Faster#83092

Merged
original-brownbear merged 7 commits intoelastic:masterfrom
original-brownbear:faster-auto-expand-replicas
Jan 26, 2022
Merged

Make AllocationService#adaptAutoExpandReplicas Faster#83092
original-brownbear merged 7 commits intoelastic:masterfrom
original-brownbear:faster-auto-expand-replicas

Conversation

@original-brownbear
Copy link
Copy Markdown
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/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 Meta label for distributed team. label Jan 25, 2022
@elasticmachine
Copy link
Copy Markdown
Collaborator

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

@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

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

private final AllocationDeciders deciders;

@Nullable
private final RoutingNodes routingNodes;
Copy link
Copy Markdown
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
Copy Markdown
Member

@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
Copy Markdown
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/Allocation All issues relating to the decision making around placing a shard (both master logic & on the nodes) >enhancement Team:Distributed Meta label for distributed team. v8.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants