Skip to content

Speed up DataTierAllocationDecider#78075

Merged
original-brownbear merged 9 commits intoelastic:masterfrom
original-brownbear:speed-up-data-tier-allocation-decider
Sep 22, 2021
Merged

Speed up DataTierAllocationDecider#78075
original-brownbear merged 9 commits intoelastic:masterfrom
original-brownbear:speed-up-data-tier-allocation-decider

Conversation

@original-brownbear
Copy link
Copy Markdown
Contributor

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
Copy Markdown
Collaborator

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

@joegallo joegallo self-requested a review September 21, 2021 15:55
@joegallo
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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


public static String[] parseTierList(String tiers) {
return Strings.tokenizeToStringArray(tiers, ",");
if (Strings.hasLength(tiers) == false) {
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

Jenkins run elasticsearch-ci/part-2

@original-brownbear
Copy link
Copy Markdown
Contributor 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 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 <joegallo@gmail.com>
@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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants