Speed up DataTierAllocationDecider#78075
Speed up DataTierAllocationDecider#78075original-brownbear merged 9 commits intoelastic:masterfrom original-brownbear:speed-up-data-tier-allocation-decider
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 |
dakrone
left a comment
There was a problem hiding this comment.
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. |
dakrone
left a comment
There was a problem hiding this comment.
LGTM, I left two really minor comments
|
|
||
| public static String[] parseTierList(String tiers) { | ||
| return Strings.tokenizeToStringArray(tiers, ","); | ||
| if (Strings.hasLength(tiers) == false) { |
There was a problem hiding this comment.
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.
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 <joegallo@gmail.com>
This decider is quite slow in
allocationAllowedand 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.