-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Speed up DataTierAllocationDecider #78075
Conversation
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.
Pinging @elastic/es-data-management (Team:Data Management) |
Do you happen to know how good are the tests here? I added an exception into |
There was a problem hiding this 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
.../main/java/org/elasticsearch/xpack/cluster/routing/allocation/DataTierAllocationDecider.java
Outdated
Show resolved
Hide resolved
.../main/java/org/elasticsearch/xpack/cluster/routing/allocation/DataTierAllocationDecider.java
Outdated
Show resolved
Hide resolved
The tierName argument is a single tier name, rather than comma separated list of zero or more tier names.
Great catch, @dakrone, I've added two commits that should address your comments. |
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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:
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 + "]"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here,
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 + "]"; |
…-allocation-decider
Jenkins run elasticsearch-ci/part-2 |
Thanks Joe + Lee! |
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]>
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]>
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.