Avoid needless index metadata builders during reroute#88506
Avoid needless index metadata builders during reroute#88506original-brownbear merged 8 commits intoelastic:masterfrom original-brownbear:avoid-needless-index-metadata-building
Conversation
…ex-metadata-building
| * @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.
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.
| */ | ||
| @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.
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.
May be keep them ass assert so that it is clear for the reader?
There was a problem hiding this comment.
++ Sure thing added :)
| 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.
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#applyChangesessentially 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