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

Small cleanups to Allocation Performance #89378

Conversation

original-brownbear
Copy link
Member

Two fixes:

  1. Looking up Custom values over and over for every shard incurs a measurable cost.
    This removes that cost for desired nodes and node shutdown metadata.
  2. Node shutdown metadata logic wasn't inlining nicely because of the wrapped map.
    No need to be as complicated as we were in many spots, use a simple immutable map
    for all operations and remove a bunch of branching.

relates #77466

Two fixes:
1. Looking up `Custom` values over and over for every shard incurs a measurable cost.
This removes that cost for desired nodes and node shutdown metadata.
2. Node shutdown metadata logic wasn't inlining nicely because of the wrapped map.
No need to be as complicated as we were in many spots, use a simple immutable map
for all operations and remove a bunch of branching.
@original-brownbear original-brownbear added >non-issue :Distributed Coordination/Allocation All issues relating to the decision making around placing a shard (both master logic & on the nodes) v8.5.0 labels Aug 16, 2022
@elasticsearchmachine elasticsearchmachine added the Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. label Aug 16, 2022
@elasticsearchmachine
Copy link
Collaborator

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

return Optional.ofNullable((NodesShutdownMetadata) this.custom(NodesShutdownMetadata.TYPE))
.map(NodesShutdownMetadata::getAllNodeMetadataMap)
.orElse(Collections.emptyMap());
return this.custom(NodesShutdownMetadata.TYPE, NodesShutdownMetadata.EMPTY).getAllNodeMetadataMap();
Copy link
Contributor

Choose a reason for hiding this comment

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

This is way simpler 👍

private final Map<String, SingleNodeShutdownMetadata> nodeShutdowns;

@Nullable
private final DesiredNodes desiredNodes;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need above to make it inline?

Copy link
Member Author

Choose a reason for hiding this comment

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

This isn't really about inlining. This is just faster outright because we don't have to lookup from the customs map for every shard.

@original-brownbear
Copy link
Member Author

Thanks Ievgen!

@original-brownbear original-brownbear merged commit 80796fb into elastic:main Aug 16, 2022
@original-brownbear original-brownbear deleted the small-cleanups-alloc-performance branch August 16, 2022 12:16
@original-brownbear original-brownbear restored the small-cleanups-alloc-performance branch April 18, 2023 20:36
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) >non-issue Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. v8.5.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants