OpenSearch icon indicating copy to clipboard operation
OpenSearch copied to clipboard

[Weighted Shard Routing] Revisit weighted routing cache

Open anshu1106 opened this issue 3 years ago • 1 comments

Describe the solution you'd like Revisit WeightedRoutingCache and see if we can make it more optimal. Currently the cache is invalidated on every cluster state change which is not needed and can affect performance.

  • Check if we can leverage AttributeRoutings which is invalidated only on change in shard routing.
 static class AttributesRoutings {

        public final List<ShardRouting> withSameAttribute;
        public final List<ShardRouting> withoutSameAttribute;
        public final int totalSize;

        AttributesRoutings(List<ShardRouting> withSameAttribute, List<ShardRouting> withoutSameAttribute) {
            this.withSameAttribute = withSameAttribute;
            this.withoutSameAttribute = withoutSameAttribute;
            this.totalSize = withoutSameAttribute.size() + withSameAttribute.size();
        }
    }
  • Make WeightedRoutingCache more performant.

anshu1106 avatar Sep 15 '22 11:09 anshu1106

https://github.com/opensearch-project/OpenSearch/pull/4241#discussion_r971681349 https://github.com/opensearch-project/OpenSearch/pull/4241#discussion_r971684094

anshu1106 avatar Sep 15 '22 13:09 anshu1106

Closing this issue. This is fixed in 4241

anshu1106 avatar Oct 06 '22 07:10 anshu1106