Skip to content

Speed up Routing Nodes Priority Comparator#78609

Merged
original-brownbear merged 2 commits intoelastic:masterfrom
original-brownbear:speed-up-priority-sort
Oct 4, 2021
Merged

Speed up Routing Nodes Priority Comparator#78609
original-brownbear merged 2 commits intoelastic:masterfrom
original-brownbear:speed-up-priority-sort

Conversation

@original-brownbear
Copy link
Copy Markdown
Contributor

This one shows up very hot if sorting a long list of shards because of the
cost of looking up the settings over and over. Lazy+best-effort caching
the two settings that get looked up significantly speeds up the routing sorting.

This one shows up very hot if sorting a long list of shards because of the
cost of looking up the settings over and over. Lazy+best-effort caching
the two settings that get looked up significantly speeds up the routing sorting.
@original-brownbear original-brownbear added >non-issue :Distributed/Allocation All issues relating to the decision making around placing a shard (both master logic & on the nodes) v8.0.0 v7.16.0 labels Oct 4, 2021
@elasticmachine elasticmachine added the Team:Distributed Meta label for distributed team. label Oct 4, 2021
@elasticmachine
Copy link
Copy Markdown
Collaborator

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

final String o1Index = o1.getIndexName();
final String o2Index = o2.getIndexName();
final Index o1Index = o1.index();
final Index o2Index = o2.index();
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.

Better compare the Index here than just their names. If we have instance equality it's the same performance as comparing names. If we have different indices, the UUID strings will compare quicker than index names because there's no common prefixes.

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.

Could we just make these final fields that get read from the settings in IndexMetadata$Builder#build()?

@original-brownbear
Copy link
Copy Markdown
Contributor Author

Could we just make these final fields that get read from the settings in IndexMetadata$Builder#build()?

🤦‍♂️ yea that's less stupid :) thanks!

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 6089669 into elastic:master Oct 4, 2021
@original-brownbear original-brownbear deleted the speed-up-priority-sort branch October 4, 2021 13:23
original-brownbear added a commit that referenced this pull request Oct 4, 2021
This one shows up very hot if sorting a long list of shards because of the
cost of looking up the settings over and over.
@original-brownbear original-brownbear restored the speed-up-priority-sort branch April 18, 2023 20:42
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) >non-issue Team:Distributed Meta label for distributed team. v7.16.0 v8.0.0-beta1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants