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

Speed up DataTierAllocationDecider #78075

Conversation

original-brownbear
Copy link
Member

This decider is quite slow in allocationAllowed and shows up in profiling.
We should be able to get a much tighter loop with this change that avoids building
the list of role names over and over and removes some dead code as well.
There's certainly additional speedups possible here though, this just deals with the most obvious issue.

This decider is quite slow in `allocationAllowed` and shows up in profiling.
We should be able to get a much tighter loop with this change that avoids building
the list of role names over and over and removes some dead code as well.
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-data-management (Team:Data Management)

@joegallo
Copy link
Contributor

joegallo commented Sep 21, 2021

Do you happen to know how good are the tests here? I added an exception into allocationAllowed and I couldn't get any failing tests out of it -- that has me on edge. (edit: it's entirely possible I'm holding it wrong, though!)

Copy link
Member

@dakrone dakrone left a comment

Choose a reason for hiding this comment

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

I left a couple of comments, I think we can simplify this more

The tierName argument is a single tier name, rather than comma
separated list of zero or more tier names.
@joegallo
Copy link
Contributor

Great catch, @dakrone, I've added two commits that should address your comments.

@joegallo joegallo requested review from dakrone and removed request for joegallo September 22, 2021 02:50
Copy link
Member

@dakrone dakrone left a comment

Choose a reason for hiding this comment

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

LGTM, I left two really minor comments

@@ -192,7 +185,12 @@ private Decision shouldIndexPreferTier(IndexMetadata indexMetadata, Set<Discover
}

public static String[] parseTierList(String tiers) {
return Strings.tokenizeToStringArray(tiers, ",");
if (Strings.hasLength(tiers) == false) {
Copy link
Member

Choose a reason for hiding this comment

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

To avoid an array like [" "] (not that we expect that), maybe we should use:

Suggested change
if (Strings.hasLength(tiers) == false) {
if (Strings.hasText(tiers) == false) {

String[] values = parseTierList(tierSetting);
for (String value : values) {
private static boolean allocationAllowed(String tierName, Set<DiscoveryNodeRole> roles) {
assert Strings.hasLength(tierName) : "tierName must be not null and non-empty, but was [" + tierName + "]";
Copy link
Member

Choose a reason for hiding this comment

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

Same here,

Suggested change
assert Strings.hasLength(tierName) : "tierName must be not null and non-empty, but was [" + tierName + "]";
assert Strings.hasText(tierName) : "tierName must be not null and non-empty, but was [" + tierName + "]";

@original-brownbear
Copy link
Member Author

Jenkins run elasticsearch-ci/part-2

@original-brownbear
Copy link
Member Author

Thanks Joe + Lee!

@original-brownbear original-brownbear merged commit 381e150 into elastic:master Sep 22, 2021
@original-brownbear original-brownbear deleted the speed-up-data-tier-allocation-decider branch September 22, 2021 09:06
original-brownbear added a commit to original-brownbear/elasticsearch that referenced this pull request Sep 22, 2021
This decider is quite slow in `allocationAllowed` and shows up in profiling.
We should be able to get a much tighter loop with this change that avoids building
the list of role names over and over and removes some dead code as well.

Co-authored-by: Joe Gallo <[email protected]>
original-brownbear added a commit that referenced this pull request Sep 22, 2021
This decider is quite slow in `allocationAllowed` and shows up in profiling.
We should be able to get a much tighter loop with this change that avoids building
the list of role names over and over and removes some dead code as well.

Co-authored-by: Joe Gallo <[email protected]>
@original-brownbear original-brownbear restored the speed-up-data-tier-allocation-decider branch April 18, 2023 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants