-
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
Avoid needless index metadata builders during reroute #88506
Avoid needless index metadata builders during reroute #88506
Conversation
…ex-metadata-building
@@ -64,13 +58,25 @@ public static <K, V> Map<K, V> copyMapWithAddedEntry(final Map<K, V> map, final | |||
* @param <V> the type of the values in the map | |||
* @return an immutable map that contains the items from the specified map and a mapping from the specified key to the specified value | |||
*/ | |||
@SuppressWarnings("unchecked") | |||
public static <K, V> Map<K, V> copyMapWithAddedOrReplacedEntry(final Map<K, V> map, final K key, final V value) { |
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.
Changes here aren't 100% necessary for this to work, but they cause the whole thing to compile far better.
Without this change there's not really any reason to improve this code though so I put it in here.
@@ -41,9 +38,6 @@ public class Maps { | |||
*/ | |||
@SuppressWarnings("unchecked") | |||
public static <K, V> Map<K, V> copyMapWithAddedEntry(final Map<K, V> map, final K key, final V value) { | |||
Objects.requireNonNull(map); |
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.
No need for these checks, they're all pointless since a null for any of the three parameters will throw an NPE below anyway.
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.
May be keep them ass assert
so that it is clear for the reader?
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.
++ Sure thing added :)
@@ -654,7 +655,8 @@ private IndexMetadata( | |||
this.autoExpandReplicas = autoExpandReplicas; | |||
this.isSearchableSnapshot = isSearchableSnapshot; | |||
this.isPartialSearchableSnapshot = isPartialSearchableSnapshot; | |||
this.indexCompatibilityVersion = SETTING_INDEX_VERSION_COMPATIBILITY.get(settings); | |||
this.indexCompatibilityVersion = indexCompatibilityVersion; | |||
assert indexCompatibilityVersion.equals(SETTING_INDEX_VERSION_COMPATIBILITY.get(settings)); |
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.
This snuck in recently making the constructor here needlessly heavy, fixed here so the copy-constructors are as fast as possible again.
Pinging @elastic/es-distributed (Team:Distributed) |
Thanks Ievgen! |
* upstream/master: (2974 commits) Reserved cluster state service (elastic#88527) Add transport action immutable state checks (elastic#88491) Remove suggest flag from index stats docs (elastic#85479) Polling cluster formation state for master-is-stable health indicator (elastic#88397) Add test execution guide in yamlRestTest asciidoc (elastic#88490) Add troubleshooting guide for corrupt repository (elastic#88391) [Transform] Finetune Schedule to be less noisy on retry and retry slower (elastic#88531) Updatable API keys - auto-update legacy RDs (elastic#88514) Fix typo in TransportForceMergeAction and TransportClearIndicesCacheA… (elastic#88064) Fixed NullPointerException on bulk request (elastic#88358) Avoid needless index metadata builders during reroute (elastic#88506) Set metadata on request in API key noop test (elastic#88507) Fix passing positional args to ES in Docker (elastic#88502) Improve description for task api detailed param (elastic#88493) Support cartesian shape with doc values (elastic#88487) Promote usage of Subjects in Authentication class (elastic#88494) Add CCx 2.0 feature flag (elastic#88451) Reword the watcher 'always' and 'never' condition docs (elastic#86105) Simplify azure discovery installation docs (elastic#88404) Breakup FIPS CI testing jobs ... # Conflicts: # server/src/main/java/org/elasticsearch/index/mapper/NumberFieldMapper.java # x-pack/plugin/mapper-aggregate-metric/src/main/java/org/elasticsearch/xpack/aggregatemetric/mapper/AggregateDoubleMetricFieldMapper.java
This set of changes makes
org.elasticsearch.cluster.routing.allocation.IndexMetadataUpdater#applyChanges
essentially free even in clusters of O(100k) indices compared to using a disproportionately increasing amount of CPU as the cluster grows (about 1% of CPU time while bootstrapping many shards at 25k indices benchmarks and increasing from there).It also appears to have additional benefits end-to-end in those benchmarks, likely as a result of making diffing metadata cheaper by retaining more instance equality across the board.
relates #77466