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 Data Tier Allocation Decider + Related Settings #78608

Conversation

original-brownbear
Copy link
Member

@original-brownbear original-brownbear commented Oct 4, 2021

  • Short circuit some string splitting loops where possible.
  • Fix very inefficient setting methods that would loop the properties
    on every lookup and/or build the default value string on every default lookup.
  • Use plain setting get instead of the setings instance get for very hot setting
  • Simplify hot path for getAsBoolean

relates #77466

addressed part of #77974 by making the boolean setting much cheaper

* Short circuit some string splitting loops where possible.
* Fix very inefficient setting methods that would loop the properties
on every lookup and/or bulid the default value string on every default lookup.
* Use plain setting get instead of the setings instance get for very hot setting
* Simplify hot path for `getAsBoolean`
@elasticmachine elasticmachine added Team:Core/Infra Meta label for core/infra team Team:Data Management Meta label for data/management team labels Oct 4, 2021
@elasticmachine
Copy link
Collaborator

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

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

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

The properties change looks good.

For looking up the boolean directly on the settings object, this is the opposite direction that we have been trying to go. It is my hope that we could eventually get rid of all the getters directly on settings objects, or at least move them into their appropriate setting instance type.

Why are settings a hot path in the first place? I think anytime we have settings on the hot path we should move the value out to a member. Settings don’t change often, or in some cases it is static for the life of an index.

@@ -25,7 +25,7 @@
private SearchableSnapshotsSettings() {}

public static boolean isSearchableSnapshotStore(Settings indexSettings) {
return SEARCHABLE_SNAPSHOT_STORE_TYPE.equals(INDEX_STORE_TYPE_SETTING.get(indexSettings));
return SEARCHABLE_SNAPSHOT_STORE_TYPE.equals(indexSettings.get(INDEX_STORE_TYPE_SETTING.getKey()));
Copy link
Member

Choose a reason for hiding this comment

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

If this is hot then we should move it to be directly represented on the IndexSettings?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yea let's do it :) I'll back this part out into a separate PR in a bit then and just leave the obvious optimizations here.

@@ -321,7 +321,21 @@ public boolean hasValue(String key) {
* returns the default value provided.
*/
public Boolean getAsBoolean(String setting, Boolean defaultValue) {
return Booleans.parseBoolean(get(setting), defaultValue);
final Object found = settings.get(setting);
if (found == null) {
Copy link
Member

Choose a reason for hiding this comment

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

Couldn’t this optimizations exist inside Booleans.parseBoolean?

@danhermann danhermann added v8.1.0 and removed v7.16.0 labels Oct 27, 2021
@original-brownbear original-brownbear removed >non-issue :Core/Infra/Settings Settings infrastructure and APIs v8.0.0 Team:Core/Infra Meta label for core/infra team Team:Data Management Meta label for data/management team v8.1.0 :Data Management/Other labels Dec 27, 2021
@original-brownbear
Copy link
Member Author

closing as this has been resolved by a different approach now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants