Skip to content

Faster ShardsLimitAllocationDecider#82251

Merged
original-brownbear merged 5 commits intoelastic:masterfrom
original-brownbear:faster-shards-limit-alloc-decider
Jan 6, 2022
Merged

Faster ShardsLimitAllocationDecider#82251
original-brownbear merged 5 commits intoelastic:masterfrom
original-brownbear:faster-shards-limit-alloc-decider

Conversation

@original-brownbear
Copy link
Copy Markdown
Contributor

As in many other cases, cache the setting value on IndexMetadata
and also don't parse the constant setting value from the static
settings on every decision and store it in a field instead of the
settings.
This one is currently the second slowest decider in tests after the disk threshold one and this makes it effectively disappear from profiling.

relates #77466

As in many other cases, cache the setting value on `IndexMetadata`
and also don't parse the constant setting value from the static
settings on every decision and store it in a field instead of the
settings.
@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 v8.1.0 labels Jan 5, 2022
@elasticmachine elasticmachine added the Team:Distributed Meta label for distributed team. label Jan 5, 2022
@elasticmachine
Copy link
Copy Markdown
Collaborator

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

Copy link
Copy Markdown
Contributor

@henningandersen henningandersen left a comment

Choose a reason for hiding this comment

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

A few smaller comments, otherwise looking good.

public ShardsLimitAllocationDecider(Settings settings, ClusterSettings clusterSettings) {
this.settings = settings;
this.clusterShardLimit = CLUSTER_TOTAL_SHARDS_PER_NODE_SETTING.get(settings);
this.indexShardLimit = INDEX_TOTAL_SHARDS_PER_NODE_SETTING.get(settings);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this is not necessary, this setting is not legal as a node setting.

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.

Right 🤦 removed this, making the rest of the code far simpler as well.

private final List<String> tierPreference;

@Nullable
private final Integer shardsPerNodeLimit;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think I would prefer to use -1 as no limit since that is the definition on the setting as well. I think an explicit -1 setting value is OK, which would cause this to have a (Integer) -1 value anyway.

Perhaps we need a test with an explicit -1 to verify this case works too (seems we do not have such a test)?

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.

Test is not necessary thanks to your comment above :) I could just use the setting outright now because we only use the setting and no fallback to node settings so we can use int and have all kinds of tests that test the setting default of -1 :)

@original-brownbear
Copy link
Copy Markdown
Contributor Author

Jenkins run elasticsearch-ci/part-2 (unrelated Gradle issue)

@original-brownbear
Copy link
Copy Markdown
Contributor Author

Thanks Henning, simplified this quite a bit now and should be good for another round :)

Copy link
Copy Markdown
Contributor

@henningandersen henningandersen left a comment

Choose a reason for hiding this comment

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

LGTM if you turn the constructor arg into an int.

@original-brownbear
Copy link
Copy Markdown
Contributor Author

Jenkins run elasticsearch-ci/part-1 (known + unrelated)

1 similar comment
@original-brownbear
Copy link
Copy Markdown
Contributor Author

Jenkins run elasticsearch-ci/part-1 (known + unrelated)

@original-brownbear
Copy link
Copy Markdown
Contributor Author

Thanks Henning!

@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

💚 Backport successful

Status Branch Result
8.0

elasticsearchmachine pushed a commit that referenced this pull request Jan 6, 2022
As in many other cases, cache the setting value on `IndexMetadata`
and also don't parse the constant setting value from the static
settings on every decision and store it in a field instead of the
settings.
astefan pushed a commit to astefan/elasticsearch that referenced this pull request Jan 7, 2022
As in many other cases, cache the setting value on `IndexMetadata`
and also don't parse the constant setting value from the static
settings on every decision and store it in a field instead of the
settings.
astefan pushed a commit to astefan/elasticsearch that referenced this pull request Jan 7, 2022
As in many other cases, cache the setting value on `IndexMetadata`
and also don't parse the constant setting value from the static
settings on every decision and store it in a field instead of the
settings.
@original-brownbear original-brownbear restored the faster-shards-limit-alloc-decider branch April 18, 2023 21:01
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. v8.0.0-rc2 v8.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants