You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by "himanshukandwal (via GitHub)" <gi...@apache.org> on 2023/10/09 22:01:13 UTC

[PR] [apache/helix] -- Fixes #2646 (Part-1), Optimize WagedInstanceCapacity Calculation to improve Helix Controller Pipeline [helix]

himanshukandwal opened a new pull request, #2649:
URL: https://github.com/apache/helix/pull/2649

   ### Issues
   
   - [x] My PR addresses the following Helix issues and references them in the PR description:
   #2646 
   
   ### Description
   WagedInstanceCapacity data-structure is computed every time during a pipeline run and in case of large clusters, this computation takes ~80% of total time and hence, it's important to improve its performance.
   
   - [x] Here are some details about my PR, including screenshots of any UI changes:
   
   In this PR, we are performing following changes:
   * Created `WagedInstanceCapacityManager` class to cleanly factor-out the operations on WagedInstanceCapacity cache. It contains the condition on when the full build of cache should or shouldn't happen. With this we are skipping the full cache building in case of `TaskCurrentStateChange`, `MessageChange`, and `Resume` events.
   * In WagedInstanceCapacity, we are creating merged ResourceConfig once to determine the partition weights for all the partitions and not every time for each partition.
   
   ### Tests
   
   - [x] `TestWagedInstanceCapacityManager`
   * testProcessEventWithNoWagedResources
   * testProcessEventWithSomeWagedResources
   * testProcessEventWithAllWagedResources
   * testShouldNoOp
   
   - [x] `TestWagedInstanceCapacity`
   * testProcessCurrentState
   * testProcessCurrentStateWithDoubleCharge
   * testProcessCurrentStateWithUnableToAssignPart
   
   - The following is the result of the "mvn test" command on the appropriate module:
   
   ```console
   mvn clean install -Dmaven.test.skip.exec=true && mvn test -o -Dtest=TestWagedInstanceCapacity,TestWagedInstanceCapacityManager -pl=helix-core
   
   1425 [main] ERROR org.apache.helix.model.IdealState [] - could NOT determine replicas. set to 0
   1438 [main] ERROR org.apache.helix.model.IdealState [] - could NOT determine replicas. set to 0
   1447 [main] ERROR org.apache.helix.model.IdealState [] - could NOT determine replicas. set to 0
   [INFO] Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.21 s - in TestSuite
   [INFO] 
   [INFO] Results:
   [INFO] 
   [INFO] Tests run: 7, Failures: 0, Errors: 0, Skipped: 0
   [INFO] 
   [INFO] 
   [INFO] --- jacoco:0.8.6:report (generate-code-coverage-report) @ helix-core ---
   [INFO] Loading execution data file /Users/hkandwal/Documents/workspaces/projects/helix_os_hk/helix-core/target/jacoco.exec
   [INFO] Analyzed bundle 'Apache Helix :: Core' with 949 classes
   [INFO] ------------------------------------------------------------------------
   [INFO] BUILD SUCCESS
   [INFO] ------------------------------------------------------------------------
   [INFO] Total time:  5.627 s
   [INFO] Finished at: 2023-10-09T15:00:30-07:00
   [INFO] ------------------------------------------------------------------------
   ```
   
   ### Changes that Break Backward Compatibility (Optional)
   
   - My PR contains changes that break backward compatibility or previous assumptions for certain methods or API. They include:
   
   (Consider including all behavior changes for public methods or API. Also include these changes in merge description so that other developers are aware of these changes. This allows them to make relevant code changes in feature branches accounting for the new method/API behavior.)
   
   ### Documentation (Optional)
   
   - In case of new functionality, my PR adds documentation in the following wiki page:
   
   (Link the GitHub wiki you added)
   
   ### Commits
   
   - My commits all reference appropriate Apache Helix GitHub issues in their subject lines. In addition, my commits follow the guidelines from "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)":
     1. Subject is separated from body by a blank line
     1. Subject is limited to 50 characters (not including Jira issue reference)
     1. Subject does not end with a period
     1. Subject uses the imperative mood ("add", not "adding")
     1. Body wraps at 72 characters
     1. Body explains "what" and "why", not "how"
   
   ### Code Quality
   
   - My diff has been formatted using helix-style.xml 
   (helix-style-intellij.xml if IntelliJ IDE is used)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


Re: [PR] [apache/helix] -- Fixes #2646 (Part-1), Optimize WagedInstanceCapacity Calculation to improve Helix Controller Pipeline [helix]

Posted by "desaikomal (via GitHub)" <gi...@apache.org>.
desaikomal commented on code in PR #2649:
URL: https://github.com/apache/helix/pull/2649#discussion_r1359505103


##########
helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/WagedInstanceCapacity.java:
##########
@@ -215,7 +221,7 @@ public synchronized boolean checkAndReduceInstanceCapacity(String instance, Stri
     }
     _allocatedPartitionsMap.computeIfAbsent(instance, k -> new HashMap<>())
         .computeIfAbsent(resName, k -> new HashSet<>()).add(partitionName);
-    LOG.info("Reduced capacity for instance: " + instance + " for resource: " + resName
+    LOG.debug("Reduced capacity for instance: " + instance + " for resource: " + resName

Review Comment:
   great ... 



##########
helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/WagedInstanceCapacity.java:
##########
@@ -130,28 +136,29 @@ public void processPendingMessages(ResourceControllerDataProvider cache,
     }
   }
 
-
-  private void processCurrentState(ResourceControllerDataProvider cache,
-      CurrentStateOutput currentStateOutput, Map<String, Resource> resourceMap,
-      WagedResourceWeightsProvider weightProvider) {
+  void processCurrentState(ResourceControllerDataProvider cache,
+      CurrentStateOutput currentStateOutput, Map<String, Resource> resourceMap) {
 
     // Iterate through all the resources
     for (Map.Entry<String, Resource> entry : resourceMap.entrySet()) {
       String resName = entry.getKey();
       Resource resource = entry.getValue();
 
-      // if Resource is WAGED managed, then we need to manage the capacity.
-      if (!WagedValidationUtil.isWagedEnabled(cache.getIdealState(resName))) {
-        continue;
-      }
-
       // list of partitions in the resource
       Collection<Partition> partitions = resource.getPartitions();
 
+      // calculate merge resource-config one for each resource.
+      ResourceConfig resourceConfig = cache.getResourceConfig(resName);
+      IdealState is = cache.getIdealState(resName);
+      ResourceConfig mergedResourceConfig =
+          ResourceConfig.mergeIdealStateWithResourceConfig(resourceConfig, is);
+
       for (Partition partition : partitions) {
         String partitionName = partition.getPartitionName();
         // Get Partition Weight
-        Map<String, Integer> partCapacity = weightProvider.getPartitionWeights(resName, partitionName);
+        Map<String, Integer> partCapacity =
+            WagedRebalanceUtil.fetchCapacityUsage(partitionName, mergedResourceConfig, cache.getClusterConfig());

Review Comment:
   you can check it in next change. Also based on Junkai comment, please evaulate if we even need it?



##########
helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/WagedInstanceCapacityManager.java:
##########
@@ -0,0 +1,119 @@
+package org.apache.helix.controller.rebalancer.waged;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
+import org.apache.helix.controller.dataproviders.BaseControllerDataProvider;
+import org.apache.helix.controller.dataproviders.ResourceControllerDataProvider;
+import org.apache.helix.controller.rebalancer.util.WagedValidationUtil;
+import org.apache.helix.controller.stages.AttributeName;
+import org.apache.helix.controller.stages.ClusterEvent;
+import org.apache.helix.controller.stages.CurrentStateOutput;
+import org.apache.helix.model.Resource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Manager class responsible for abstracting the management operations on the {@link WagedInstanceCapacity}
+ * cache such as rebuild and update operations on various scenarios.
+ */
+public class WagedInstanceCapacityManager {
+
+  private static final Logger LOG = LoggerFactory.getLogger(WagedInstanceCapacityManager.class);
+
+  private static class SingletonHelper {
+    private static final WagedInstanceCapacityManager INSTANCE = new WagedInstanceCapacityManager();
+  }
+
+  public static WagedInstanceCapacityManager getInstance() {
+    return SingletonHelper.INSTANCE;
+  }
+
+  public void processEvent(ClusterEvent event, CurrentStateOutput currentStateOutput) {
+    BaseControllerDataProvider cache = event.getAttribute(AttributeName.ControllerDataProvider.name());
+    final Map<String, Resource> resourceMap = event.getAttribute(AttributeName.RESOURCES.name());
+
+    if (shouldNoOp(cache, resourceMap, event)) {
+      return;
+    }
+
+    ResourceControllerDataProvider dataProvider = (ResourceControllerDataProvider) cache;
+    Map<String, Resource> wagedEnabledResourceMap = resourceMap.entrySet()
+        .stream()
+        .filter(entry -> WagedValidationUtil.isWagedEnabled(cache.getIdealState(entry.getKey())))
+        .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
+
+    if (wagedEnabledResourceMap.isEmpty()) {
+      return;
+    }
+
+    // Phase 1: Rebuild Always
+    // DONE: we only need to compute when there are resource using Waged. We should
+    // do this as perf improvement in the future.
+    WagedInstanceCapacity capacityProvider = new WagedInstanceCapacity(dataProvider);
+    WagedResourceWeightsProvider weightProvider = new WagedResourceWeightsProvider(dataProvider);
+
+    // Process the currentState and update the available instance capacity.
+    capacityProvider.process(dataProvider, currentStateOutput, wagedEnabledResourceMap, weightProvider);
+    dataProvider.setWagedCapacityProviders(capacityProvider, weightProvider);
+  }
+
+  /**
+   * Function that checks whether we should return early, without any action on the capacity map or not.
+   * @param cache it is the cluster level cache for the resources.
+   * @param event the cluster event that is undergoing processing.
+   * @return true, of the condition evaluate to true and no action is needed, else false.
+   */
+  static boolean shouldNoOp(BaseControllerDataProvider cache, Map<String, Resource> resourceMap, ClusterEvent event) {
+    if (!(cache instanceof ResourceControllerDataProvider)) {
+      return true;
+    }
+
+    if (resourceMap == null || resourceMap.isEmpty()) {
+      return true;
+    }
+
+    ResourceControllerDataProvider dataProvider = (ResourceControllerDataProvider) cache;
+    if (Objects.isNull(dataProvider.getWagedInstanceCapacity())) {
+      return false;
+    }
+
+    switch (event.getEventType()) {

Review Comment:
   essentially, we need to recompute only for few events, so may be having other way check may be good



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


Re: [PR] [apache/helix] -- Fixes #2646 (Part-1), Optimize WagedInstanceCapacity Calculation to improve Helix Controller Pipeline [helix]

Posted by "himanshukandwal (via GitHub)" <gi...@apache.org>.
himanshukandwal commented on PR #2649:
URL: https://github.com/apache/helix/pull/2649#issuecomment-1756008409

   > Initial comments. will do second pass later. THANKS a lot for working. wondering if we can have some profile numbers
   
   Yes, this is quite important. I am working on the Integ test and will share the numbers.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


Re: [PR] [apache/helix] -- Fixes #2646 (Part-1), Optimize WagedInstanceCapacity Calculation to improve Helix Controller Pipeline [helix]

Posted by "himanshukandwal (via GitHub)" <gi...@apache.org>.
himanshukandwal commented on PR #2649:
URL: https://github.com/apache/helix/pull/2649#issuecomment-1771838585

   This PR is approved by @junkaixue and is ready to be merged.
   
   Final commit message:
   WagedInstanceCapacity data-structure is computed every time during a pipeline run and in case of large clusters, this computation takes ~80% of total time. Hence, in this PR we are skipping certain cluster events when this cache should not be rebuild, and improving the overall runtime.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


Re: [PR] [apache/helix] -- Fixes #2646 (Part-1), Optimize WagedInstanceCapacity Calculation to improve Helix Controller Pipeline [helix]

Posted by "himanshukandwal (via GitHub)" <gi...@apache.org>.
himanshukandwal commented on code in PR #2649:
URL: https://github.com/apache/helix/pull/2649#discussion_r1363385805


##########
helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/WagedInstanceCapacityManager.java:
##########
@@ -0,0 +1,119 @@
+package org.apache.helix.controller.rebalancer.waged;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
+import org.apache.helix.controller.dataproviders.BaseControllerDataProvider;
+import org.apache.helix.controller.dataproviders.ResourceControllerDataProvider;
+import org.apache.helix.controller.rebalancer.util.WagedValidationUtil;
+import org.apache.helix.controller.stages.AttributeName;
+import org.apache.helix.controller.stages.ClusterEvent;
+import org.apache.helix.controller.stages.CurrentStateOutput;
+import org.apache.helix.model.Resource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Manager class responsible for abstracting the management operations on the {@link WagedInstanceCapacity}
+ * cache such as rebuild and update operations on various scenarios.
+ */
+public class WagedInstanceCapacityManager {
+
+  private static final Logger LOG = LoggerFactory.getLogger(WagedInstanceCapacityManager.class);
+
+  private static class SingletonHelper {
+    private static final WagedInstanceCapacityManager INSTANCE = new WagedInstanceCapacityManager();
+  }
+
+  public static WagedInstanceCapacityManager getInstance() {
+    return SingletonHelper.INSTANCE;
+  }
+
+  public void processEvent(ClusterEvent event, CurrentStateOutput currentStateOutput) {
+    BaseControllerDataProvider cache = event.getAttribute(AttributeName.ControllerDataProvider.name());
+    final Map<String, Resource> resourceMap = event.getAttribute(AttributeName.RESOURCES.name());
+
+    if (shouldNoOp(cache, resourceMap, event)) {
+      return;
+    }
+
+    ResourceControllerDataProvider dataProvider = (ResourceControllerDataProvider) cache;
+    Map<String, Resource> wagedEnabledResourceMap = resourceMap.entrySet()
+        .stream()
+        .filter(entry -> WagedValidationUtil.isWagedEnabled(cache.getIdealState(entry.getKey())))
+        .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
+
+    if (wagedEnabledResourceMap.isEmpty()) {
+      return;
+    }
+
+    // Phase 1: Rebuild Always
+    // DONE: we only need to compute when there are resource using Waged. We should
+    // do this as perf improvement in the future.
+    WagedInstanceCapacity capacityProvider = new WagedInstanceCapacity(dataProvider);
+    WagedResourceWeightsProvider weightProvider = new WagedResourceWeightsProvider(dataProvider);
+
+    // Process the currentState and update the available instance capacity.
+    capacityProvider.process(dataProvider, currentStateOutput, wagedEnabledResourceMap, weightProvider);
+    dataProvider.setWagedCapacityProviders(capacityProvider, weightProvider);
+  }
+
+  /**
+   * Function that checks whether we should return early, without any action on the capacity map or not.
+   * @param cache it is the cluster level cache for the resources.
+   * @param event the cluster event that is undergoing processing.
+   * @return true, of the condition evaluate to true and no action is needed, else false.
+   */
+  static boolean shouldNoOp(BaseControllerDataProvider cache, Map<String, Resource> resourceMap, ClusterEvent event) {
+    if (!(cache instanceof ResourceControllerDataProvider)) {
+      return true;
+    }
+
+    if (resourceMap == null || resourceMap.isEmpty()) {
+      return true;
+    }
+
+    ResourceControllerDataProvider dataProvider = (ResourceControllerDataProvider) cache;
+    if (Objects.isNull(dataProvider.getWagedInstanceCapacity())) {
+      return false;
+    }
+
+    switch (event.getEventType()) {

Review Comment:
   Yes, changed it to other way, Thanks!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


Re: [PR] [apache/helix] -- Fixes #2646 (Part-1), Optimize WagedInstanceCapacity Calculation to improve Helix Controller Pipeline [helix]

Posted by "desaikomal (via GitHub)" <gi...@apache.org>.
desaikomal commented on code in PR #2649:
URL: https://github.com/apache/helix/pull/2649#discussion_r1352783387


##########
helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/WagedInstanceCapacity.java:
##########
@@ -130,28 +136,29 @@ public void processPendingMessages(ResourceControllerDataProvider cache,
     }
   }
 
-
-  private void processCurrentState(ResourceControllerDataProvider cache,
-      CurrentStateOutput currentStateOutput, Map<String, Resource> resourceMap,
-      WagedResourceWeightsProvider weightProvider) {
+  void processCurrentState(ResourceControllerDataProvider cache,
+      CurrentStateOutput currentStateOutput, Map<String, Resource> resourceMap) {
 
     // Iterate through all the resources
     for (Map.Entry<String, Resource> entry : resourceMap.entrySet()) {
       String resName = entry.getKey();
       Resource resource = entry.getValue();
 
-      // if Resource is WAGED managed, then we need to manage the capacity.
-      if (!WagedValidationUtil.isWagedEnabled(cache.getIdealState(resName))) {
-        continue;
-      }
-
       // list of partitions in the resource
       Collection<Partition> partitions = resource.getPartitions();
 
+      // calculate merge resource-config one for each resource.
+      ResourceConfig resourceConfig = cache.getResourceConfig(resName);
+      IdealState is = cache.getIdealState(resName);
+      ResourceConfig mergedResourceConfig =
+          ResourceConfig.mergeIdealStateWithResourceConfig(resourceConfig, is);
+
       for (Partition partition : partitions) {
         String partitionName = partition.getPartitionName();
         // Get Partition Weight
-        Map<String, Integer> partCapacity = weightProvider.getPartitionWeights(resName, partitionName);
+        Map<String, Integer> partCapacity =
+            WagedRebalanceUtil.fetchCapacityUsage(partitionName, mergedResourceConfig, cache.getClusterConfig());

Review Comment:
   i have 2 questions: 1. do we need to update mergedResourceConfig everytime?   2.  resource/partition weight doesn't change frequently. so where are we caching this value?



##########
helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/WagedInstanceCapacity.java:
##########
@@ -130,28 +136,29 @@ public void processPendingMessages(ResourceControllerDataProvider cache,
     }
   }
 
-
-  private void processCurrentState(ResourceControllerDataProvider cache,
-      CurrentStateOutput currentStateOutput, Map<String, Resource> resourceMap,
-      WagedResourceWeightsProvider weightProvider) {
+  void processCurrentState(ResourceControllerDataProvider cache,
+      CurrentStateOutput currentStateOutput, Map<String, Resource> resourceMap) {
 
     // Iterate through all the resources
     for (Map.Entry<String, Resource> entry : resourceMap.entrySet()) {
       String resName = entry.getKey();
       Resource resource = entry.getValue();
 
-      // if Resource is WAGED managed, then we need to manage the capacity.

Review Comment:
   I am assuming you moved the check for WAGED resource somewhere else? 
   



##########
helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/WagedInstanceCapacityManager.java:
##########
@@ -0,0 +1,111 @@
+package org.apache.helix.controller.rebalancer.waged;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
+import org.apache.helix.controller.dataproviders.BaseControllerDataProvider;
+import org.apache.helix.controller.dataproviders.ResourceControllerDataProvider;
+import org.apache.helix.controller.rebalancer.util.WagedValidationUtil;
+import org.apache.helix.controller.stages.AttributeName;
+import org.apache.helix.controller.stages.ClusterEvent;
+import org.apache.helix.controller.stages.CurrentStateOutput;
+import org.apache.helix.model.Resource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Manager class responsible for abstracting the management operations on the {@link WagedInstanceCapacity}
+ * cache such as rebuild and update operations on various scenarios.
+ */
+public class WagedInstanceCapacityManager {
+
+  private static final Logger LOG = LoggerFactory.getLogger(WagedInstanceCapacityManager.class);
+
+  private static class SingletonHelper {
+    private static final WagedInstanceCapacityManager INSTANCE = new WagedInstanceCapacityManager();
+  }
+
+  public static WagedInstanceCapacityManager getInstance() {
+    return SingletonHelper.INSTANCE;
+  }
+
+  public void processEvent(ClusterEvent event, CurrentStateOutput currentStateOutput) {
+    BaseControllerDataProvider cache = event.getAttribute(AttributeName.ControllerDataProvider.name());
+    final Map<String, Resource> resourceMap = event.getAttribute(AttributeName.RESOURCES.name());
+
+    if (shouldNoOp(cache, resourceMap, event)) {
+      return;
+    }
+
+    ResourceControllerDataProvider dataProvider = (ResourceControllerDataProvider) cache;
+    Map<String, Resource> wagedEnabledResourceMap = resourceMap.entrySet()
+        .stream()
+        .filter(entry -> WagedValidationUtil.isWagedEnabled(cache.getIdealState(entry.getKey())))
+        .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
+
+    if (wagedEnabledResourceMap.isEmpty()) {
+      return;
+    }
+
+    // Phase 1: Rebuild Always
+    // DONE: we only need to compute when there are resource using Waged. We should
+    // do this as perf improvement in the future.
+    WagedInstanceCapacity capacityProvider = new WagedInstanceCapacity(dataProvider);
+    WagedResourceWeightsProvider weightProvider = new WagedResourceWeightsProvider(dataProvider);
+
+    // Process the currentState and update the available instance capacity.
+    capacityProvider.process(dataProvider, currentStateOutput, wagedEnabledResourceMap, weightProvider);
+    dataProvider.setWagedCapacityProviders(capacityProvider, weightProvider);
+  }
+
+  /**
+   * Function that checks whether we should return early, without any action on the capacity map or not.
+   * @param cache it is the cluster level cache for the resources.
+   * @param event the cluster event that is undergoing processing.
+   * @return true, of the condition evaluate to true and no action is needed, else false.
+   */
+  static boolean shouldNoOp(BaseControllerDataProvider cache, Map<String, Resource> resourceMap, ClusterEvent event) {
+    if (!(cache instanceof ResourceControllerDataProvider)) {
+      return true;
+    }
+
+    if (resourceMap == null || resourceMap.isEmpty()) {
+      return true;
+    }
+
+    ResourceControllerDataProvider dataProvider = (ResourceControllerDataProvider) cache;
+    if (Objects.isNull(dataProvider.getWagedInstanceCapacity())) {
+      return false;
+    }
+
+    switch (event.getEventType()) {
+      case TaskCurrentStateChange:
+      case MessageChange:

Review Comment:
   Looking at ClusterEventType, there are many events for which we can skip re-building cache. 
   -  IdealStateChange,  CustomizedStateChange,  CustomizeStateConfigChange,  ExternalViewChange,   CustomizedViewChange,   TargetExternalViewChange,   PeriodicalRebalance,   OnDemandRebalance,     RetryRebalance,
     StateVerifier 
   
    



##########
helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/WagedInstanceCapacityManager.java:
##########
@@ -0,0 +1,111 @@
+package org.apache.helix.controller.rebalancer.waged;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
+import org.apache.helix.controller.dataproviders.BaseControllerDataProvider;
+import org.apache.helix.controller.dataproviders.ResourceControllerDataProvider;
+import org.apache.helix.controller.rebalancer.util.WagedValidationUtil;
+import org.apache.helix.controller.stages.AttributeName;
+import org.apache.helix.controller.stages.ClusterEvent;
+import org.apache.helix.controller.stages.CurrentStateOutput;
+import org.apache.helix.model.Resource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Manager class responsible for abstracting the management operations on the {@link WagedInstanceCapacity}
+ * cache such as rebuild and update operations on various scenarios.
+ */
+public class WagedInstanceCapacityManager {
+
+  private static final Logger LOG = LoggerFactory.getLogger(WagedInstanceCapacityManager.class);
+
+  private static class SingletonHelper {
+    private static final WagedInstanceCapacityManager INSTANCE = new WagedInstanceCapacityManager();
+  }
+
+  public static WagedInstanceCapacityManager getInstance() {
+    return SingletonHelper.INSTANCE;
+  }
+
+  public void processEvent(ClusterEvent event, CurrentStateOutput currentStateOutput) {
+    BaseControllerDataProvider cache = event.getAttribute(AttributeName.ControllerDataProvider.name());
+    final Map<String, Resource> resourceMap = event.getAttribute(AttributeName.RESOURCES.name());
+
+    if (shouldNoOp(cache, resourceMap, event)) {
+      return;
+    }
+
+    ResourceControllerDataProvider dataProvider = (ResourceControllerDataProvider) cache;
+    Map<String, Resource> wagedEnabledResourceMap = resourceMap.entrySet()
+        .stream()
+        .filter(entry -> WagedValidationUtil.isWagedEnabled(cache.getIdealState(entry.getKey())))
+        .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
+
+    if (wagedEnabledResourceMap.isEmpty()) {
+      return;
+    }
+
+    // Phase 1: Rebuild Always
+    // DONE: we only need to compute when there are resource using Waged. We should
+    // do this as perf improvement in the future.
+    WagedInstanceCapacity capacityProvider = new WagedInstanceCapacity(dataProvider);
+    WagedResourceWeightsProvider weightProvider = new WagedResourceWeightsProvider(dataProvider);
+
+    // Process the currentState and update the available instance capacity.
+    capacityProvider.process(dataProvider, currentStateOutput, wagedEnabledResourceMap, weightProvider);
+    dataProvider.setWagedCapacityProviders(capacityProvider, weightProvider);
+  }
+
+  /**
+   * Function that checks whether we should return early, without any action on the capacity map or not.
+   * @param cache it is the cluster level cache for the resources.
+   * @param event the cluster event that is undergoing processing.
+   * @return true, of the condition evaluate to true and no action is needed, else false.
+   */
+  static boolean shouldNoOp(BaseControllerDataProvider cache, Map<String, Resource> resourceMap, ClusterEvent event) {
+    if (!(cache instanceof ResourceControllerDataProvider)) {
+      return true;
+    }
+
+    if (resourceMap == null || resourceMap.isEmpty()) {
+      return true;
+    }
+
+    ResourceControllerDataProvider dataProvider = (ResourceControllerDataProvider) cache;
+    if (Objects.isNull(dataProvider.getWagedInstanceCapacity())) {
+      return false;
+    }
+
+    switch (event.getEventType()) {
+      case TaskCurrentStateChange:
+      case MessageChange:

Review Comment:
   MessageChange - won't this result in change in pendingMessages ? 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


Re: [PR] [apache/helix] -- Fixes #2646 (Part-1), Optimize WagedInstanceCapacity Calculation to improve Helix Controller Pipeline [helix]

Posted by "himanshukandwal (via GitHub)" <gi...@apache.org>.
himanshukandwal commented on code in PR #2649:
URL: https://github.com/apache/helix/pull/2649#discussion_r1363369703


##########
helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/WagedInstanceCapacity.java:
##########
@@ -130,28 +136,29 @@ public void processPendingMessages(ResourceControllerDataProvider cache,
     }
   }
 
-
-  private void processCurrentState(ResourceControllerDataProvider cache,
-      CurrentStateOutput currentStateOutput, Map<String, Resource> resourceMap,
-      WagedResourceWeightsProvider weightProvider) {
+  void processCurrentState(ResourceControllerDataProvider cache,
+      CurrentStateOutput currentStateOutput, Map<String, Resource> resourceMap) {
 
     // Iterate through all the resources
     for (Map.Entry<String, Resource> entry : resourceMap.entrySet()) {
       String resName = entry.getKey();
       Resource resource = entry.getValue();
 
-      // if Resource is WAGED managed, then we need to manage the capacity.
-      if (!WagedValidationUtil.isWagedEnabled(cache.getIdealState(resName))) {
-        continue;
-      }
-
       // list of partitions in the resource
       Collection<Partition> partitions = resource.getPartitions();
 
+      // calculate merge resource-config one for each resource.
+      ResourceConfig resourceConfig = cache.getResourceConfig(resName);
+      IdealState is = cache.getIdealState(resName);
+      ResourceConfig mergedResourceConfig =
+          ResourceConfig.mergeIdealStateWithResourceConfig(resourceConfig, is);

Review Comment:
   Yes, this merge operation is not needed as partition capacity map is directly present in the ResourceConfig. I have also updated this in `WagedResourceWeightsProvider`. Thanks!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


Re: [PR] [apache/helix] -- Fixes #2646 (Part-1), Optimize WagedInstanceCapacity Calculation to improve Helix Controller Pipeline [helix]

Posted by "himanshukandwal (via GitHub)" <gi...@apache.org>.
himanshukandwal commented on PR #2649:
URL: https://github.com/apache/helix/pull/2649#issuecomment-1761794683

   > > Initial comments. will do second pass later. THANKS a lot for working. wondering if we can have some profile numbers
   > 
   
   Hey @desaikomal here are the results from the performance testing (CurrentStateComputationStage):
   
   ```
   durationWithComputation: 502, durationWithoutComputation: 32, pctDecrease: 93.0
   durationWithComputation: 996, durationWithoutComputation: 29, pctDecrease: 97.0
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


Re: [PR] [apache/helix] -- Fixes #2646 (Part-1), Optimize WagedInstanceCapacity Calculation to improve Helix Controller Pipeline [helix]

Posted by "himanshukandwal (via GitHub)" <gi...@apache.org>.
himanshukandwal commented on code in PR #2649:
URL: https://github.com/apache/helix/pull/2649#discussion_r1364711406


##########
helix-core/src/main/java/org/apache/helix/controller/stages/CurrentStateComputationStage.java:
##########
@@ -339,4 +333,61 @@ private void reportResourcePartitionCapacityMetrics(ExecutorService executorServ
       return null;
     });
   }
+
+  void handleResourceCapacityCalculation(ClusterEvent event, ResourceControllerDataProvider cache,
+      CurrentStateOutput currentStateOutput) {
+    Map<String, Resource> resourceMap = event.getAttribute(AttributeName.RESOURCES.name());
+    if (skipCapacityCalculation(cache, resourceMap, event)) {
+      return;
+    }
+
+    Map<String, Resource> wagedEnabledResourceMap = resourceMap.entrySet()
+        .stream()

Review Comment:
   Yes, updated. Thanks Junkai!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


Re: [PR] [apache/helix] -- Fixes #2646 (Part-1), Optimize WagedInstanceCapacity Calculation to improve Helix Controller Pipeline [helix]

Posted by "himanshukandwal (via GitHub)" <gi...@apache.org>.
himanshukandwal commented on code in PR #2649:
URL: https://github.com/apache/helix/pull/2649#discussion_r1363370155


##########
helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/WagedInstanceCapacityManager.java:
##########
@@ -0,0 +1,119 @@
+package org.apache.helix.controller.rebalancer.waged;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
+import org.apache.helix.controller.dataproviders.BaseControllerDataProvider;
+import org.apache.helix.controller.dataproviders.ResourceControllerDataProvider;
+import org.apache.helix.controller.rebalancer.util.WagedValidationUtil;
+import org.apache.helix.controller.stages.AttributeName;
+import org.apache.helix.controller.stages.ClusterEvent;
+import org.apache.helix.controller.stages.CurrentStateOutput;
+import org.apache.helix.model.Resource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Manager class responsible for abstracting the management operations on the {@link WagedInstanceCapacity}
+ * cache such as rebuild and update operations on various scenarios.
+ */
+public class WagedInstanceCapacityManager {

Review Comment:
   Yes, thats correct. I have removed this class now. Thanks Junkai!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


Re: [PR] [apache/helix] -- Fixes #2646 (Part-1), Optimize WagedInstanceCapacity Calculation to improve Helix Controller Pipeline [helix]

Posted by "himanshukandwal (via GitHub)" <gi...@apache.org>.
himanshukandwal commented on code in PR #2649:
URL: https://github.com/apache/helix/pull/2649#discussion_r1353052008


##########
helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/WagedInstanceCapacity.java:
##########
@@ -130,28 +136,29 @@ public void processPendingMessages(ResourceControllerDataProvider cache,
     }
   }
 
-
-  private void processCurrentState(ResourceControllerDataProvider cache,
-      CurrentStateOutput currentStateOutput, Map<String, Resource> resourceMap,
-      WagedResourceWeightsProvider weightProvider) {
+  void processCurrentState(ResourceControllerDataProvider cache,
+      CurrentStateOutput currentStateOutput, Map<String, Resource> resourceMap) {
 
     // Iterate through all the resources
     for (Map.Entry<String, Resource> entry : resourceMap.entrySet()) {
       String resName = entry.getKey();
       Resource resource = entry.getValue();
 
-      // if Resource is WAGED managed, then we need to manage the capacity.

Review Comment:
   Yes this has been moved to `WagedInstanceCapacityManager`, as we are passing in only WAGED enabled `Map<String, Resource> resourceMap`.  



##########
helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/WagedInstanceCapacityManager.java:
##########
@@ -0,0 +1,111 @@
+package org.apache.helix.controller.rebalancer.waged;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
+import org.apache.helix.controller.dataproviders.BaseControllerDataProvider;
+import org.apache.helix.controller.dataproviders.ResourceControllerDataProvider;
+import org.apache.helix.controller.rebalancer.util.WagedValidationUtil;
+import org.apache.helix.controller.stages.AttributeName;
+import org.apache.helix.controller.stages.ClusterEvent;
+import org.apache.helix.controller.stages.CurrentStateOutput;
+import org.apache.helix.model.Resource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Manager class responsible for abstracting the management operations on the {@link WagedInstanceCapacity}
+ * cache such as rebuild and update operations on various scenarios.
+ */
+public class WagedInstanceCapacityManager {
+
+  private static final Logger LOG = LoggerFactory.getLogger(WagedInstanceCapacityManager.class);
+
+  private static class SingletonHelper {
+    private static final WagedInstanceCapacityManager INSTANCE = new WagedInstanceCapacityManager();
+  }
+
+  public static WagedInstanceCapacityManager getInstance() {
+    return SingletonHelper.INSTANCE;
+  }
+
+  public void processEvent(ClusterEvent event, CurrentStateOutput currentStateOutput) {
+    BaseControllerDataProvider cache = event.getAttribute(AttributeName.ControllerDataProvider.name());
+    final Map<String, Resource> resourceMap = event.getAttribute(AttributeName.RESOURCES.name());
+
+    if (shouldNoOp(cache, resourceMap, event)) {
+      return;
+    }
+
+    ResourceControllerDataProvider dataProvider = (ResourceControllerDataProvider) cache;
+    Map<String, Resource> wagedEnabledResourceMap = resourceMap.entrySet()
+        .stream()
+        .filter(entry -> WagedValidationUtil.isWagedEnabled(cache.getIdealState(entry.getKey())))
+        .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
+
+    if (wagedEnabledResourceMap.isEmpty()) {
+      return;
+    }
+
+    // Phase 1: Rebuild Always
+    // DONE: we only need to compute when there are resource using Waged. We should
+    // do this as perf improvement in the future.
+    WagedInstanceCapacity capacityProvider = new WagedInstanceCapacity(dataProvider);
+    WagedResourceWeightsProvider weightProvider = new WagedResourceWeightsProvider(dataProvider);
+
+    // Process the currentState and update the available instance capacity.
+    capacityProvider.process(dataProvider, currentStateOutput, wagedEnabledResourceMap, weightProvider);
+    dataProvider.setWagedCapacityProviders(capacityProvider, weightProvider);
+  }
+
+  /**
+   * Function that checks whether we should return early, without any action on the capacity map or not.
+   * @param cache it is the cluster level cache for the resources.
+   * @param event the cluster event that is undergoing processing.
+   * @return true, of the condition evaluate to true and no action is needed, else false.
+   */
+  static boolean shouldNoOp(BaseControllerDataProvider cache, Map<String, Resource> resourceMap, ClusterEvent event) {
+    if (!(cache instanceof ResourceControllerDataProvider)) {
+      return true;
+    }
+
+    if (resourceMap == null || resourceMap.isEmpty()) {
+      return true;
+    }
+
+    ResourceControllerDataProvider dataProvider = (ResourceControllerDataProvider) cache;
+    if (Objects.isNull(dataProvider.getWagedInstanceCapacity())) {
+      return false;
+    }
+
+    switch (event.getEventType()) {
+      case TaskCurrentStateChange:
+      case MessageChange:

Review Comment:
   Actually yes, let me add these. Thanks @desaikomal 



##########
helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/WagedInstanceCapacity.java:
##########
@@ -130,28 +136,29 @@ public void processPendingMessages(ResourceControllerDataProvider cache,
     }
   }
 
-
-  private void processCurrentState(ResourceControllerDataProvider cache,
-      CurrentStateOutput currentStateOutput, Map<String, Resource> resourceMap,
-      WagedResourceWeightsProvider weightProvider) {
+  void processCurrentState(ResourceControllerDataProvider cache,
+      CurrentStateOutput currentStateOutput, Map<String, Resource> resourceMap) {
 
     // Iterate through all the resources
     for (Map.Entry<String, Resource> entry : resourceMap.entrySet()) {
       String resName = entry.getKey();
       Resource resource = entry.getValue();
 
-      // if Resource is WAGED managed, then we need to manage the capacity.
-      if (!WagedValidationUtil.isWagedEnabled(cache.getIdealState(resName))) {
-        continue;
-      }
-
       // list of partitions in the resource
       Collection<Partition> partitions = resource.getPartitions();
 
+      // calculate merge resource-config one for each resource.
+      ResourceConfig resourceConfig = cache.getResourceConfig(resName);
+      IdealState is = cache.getIdealState(resName);
+      ResourceConfig mergedResourceConfig =
+          ResourceConfig.mergeIdealStateWithResourceConfig(resourceConfig, is);
+
       for (Partition partition : partitions) {
         String partitionName = partition.getPartitionName();
         // Get Partition Weight
-        Map<String, Integer> partCapacity = weightProvider.getPartitionWeights(resName, partitionName);
+        Map<String, Integer> partCapacity =
+            WagedRebalanceUtil.fetchCapacityUsage(partitionName, mergedResourceConfig, cache.getClusterConfig());

Review Comment:
   So earlier, we were computing `mergedResourceConfig` everytime i.e. for each partition of a resource. Now, we are computing this at resource level, and using same for all partitions.
   
   We can cache it as well. Can I do it as part of next PR as to keep the size of this limited and bringing one change at a time..



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


Re: [PR] [apache/helix] -- Fixes #2646 (Part-1), Optimize WagedInstanceCapacity Calculation to improve Helix Controller Pipeline [helix]

Posted by "himanshukandwal (via GitHub)" <gi...@apache.org>.
himanshukandwal commented on code in PR #2649:
URL: https://github.com/apache/helix/pull/2649#discussion_r1364900496


##########
helix-core/src/main/java/org/apache/helix/controller/stages/CurrentStateComputationStage.java:
##########
@@ -339,4 +333,61 @@ private void reportResourcePartitionCapacityMetrics(ExecutorService executorServ
       return null;
     });
   }
+
+  void handleResourceCapacityCalculation(ClusterEvent event, ResourceControllerDataProvider cache,
+      CurrentStateOutput currentStateOutput) {
+    Map<String, Resource> resourceMap = event.getAttribute(AttributeName.RESOURCES.name());
+    if (skipCapacityCalculation(cache, resourceMap, event)) {
+      return;
+    }
+
+    Map<String, Resource> wagedEnabledResourceMap = resourceMap.entrySet()
+        .stream()
+        .filter(entry -> WagedValidationUtil.isWagedEnabled(cache.getIdealState(entry.getKey())))
+        .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
+
+    if (wagedEnabledResourceMap.isEmpty()) {
+      return;
+    }
+
+    // Phase 1: Rebuild Always
+    WagedInstanceCapacity capacityProvider = new WagedInstanceCapacity(cache);
+    WagedResourceWeightsProvider weightProvider = new WagedResourceWeightsProvider(cache);
+
+    capacityProvider.process(cache, currentStateOutput, wagedEnabledResourceMap, weightProvider);
+    cache.setWagedCapacityProviders(capacityProvider, weightProvider);
+  }
+
+  /**
+   * Function that checks whether we should return early, without any action on the capacity map or not.
+   *
+   * @param cache it is the cluster level cache for the resources.
+   * @param event the cluster event that is undergoing processing.
+   * @return true, of the condition evaluate to true and no action is needed, else false.
+   */
+  static boolean skipCapacityCalculation(ResourceControllerDataProvider cache, Map<String, Resource> resourceMap,
+      ClusterEvent event) {
+    if (resourceMap == null || resourceMap.isEmpty()) {
+      return true;
+    }
+
+    if (Objects.isNull(cache.getWagedInstanceCapacity())) {
+      return false;
+    }
+
+    switch (event.getEventType()) {
+      case ClusterConfigChange:
+      case InstanceConfigChange:
+      case ResourceConfigChange:
+      case ControllerChange:
+      case LiveInstanceChange:
+      case CurrentStateChange:
+      case PeriodicalRebalance:
+      case MessageChange:
+        return false;
+      default:
+        return true;
+    }
+  }

Review Comment:
   Thanks Junkai. Discussed offline, I have added a TODO to revisit and handle this logic by event-type and depending on the resource type.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


Re: [PR] [apache/helix] -- Fixes #2646 (Part-1), Optimize WagedInstanceCapacity Calculation to improve Helix Controller Pipeline [helix]

Posted by "xyuanlu (via GitHub)" <gi...@apache.org>.
xyuanlu merged PR #2649:
URL: https://github.com/apache/helix/pull/2649


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


Re: [PR] [apache/helix] -- Fixes #2646 (Part-1), Optimize WagedInstanceCapacity Calculation to improve Helix Controller Pipeline [helix]

Posted by "himanshukandwal (via GitHub)" <gi...@apache.org>.
himanshukandwal commented on code in PR #2649:
URL: https://github.com/apache/helix/pull/2649#discussion_r1353107235


##########
helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/WagedInstanceCapacityManager.java:
##########
@@ -0,0 +1,111 @@
+package org.apache.helix.controller.rebalancer.waged;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
+import org.apache.helix.controller.dataproviders.BaseControllerDataProvider;
+import org.apache.helix.controller.dataproviders.ResourceControllerDataProvider;
+import org.apache.helix.controller.rebalancer.util.WagedValidationUtil;
+import org.apache.helix.controller.stages.AttributeName;
+import org.apache.helix.controller.stages.ClusterEvent;
+import org.apache.helix.controller.stages.CurrentStateOutput;
+import org.apache.helix.model.Resource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Manager class responsible for abstracting the management operations on the {@link WagedInstanceCapacity}
+ * cache such as rebuild and update operations on various scenarios.
+ */
+public class WagedInstanceCapacityManager {
+
+  private static final Logger LOG = LoggerFactory.getLogger(WagedInstanceCapacityManager.class);
+
+  private static class SingletonHelper {
+    private static final WagedInstanceCapacityManager INSTANCE = new WagedInstanceCapacityManager();
+  }
+
+  public static WagedInstanceCapacityManager getInstance() {
+    return SingletonHelper.INSTANCE;
+  }
+
+  public void processEvent(ClusterEvent event, CurrentStateOutput currentStateOutput) {
+    BaseControllerDataProvider cache = event.getAttribute(AttributeName.ControllerDataProvider.name());
+    final Map<String, Resource> resourceMap = event.getAttribute(AttributeName.RESOURCES.name());
+
+    if (shouldNoOp(cache, resourceMap, event)) {
+      return;
+    }
+
+    ResourceControllerDataProvider dataProvider = (ResourceControllerDataProvider) cache;
+    Map<String, Resource> wagedEnabledResourceMap = resourceMap.entrySet()
+        .stream()
+        .filter(entry -> WagedValidationUtil.isWagedEnabled(cache.getIdealState(entry.getKey())))
+        .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
+
+    if (wagedEnabledResourceMap.isEmpty()) {
+      return;
+    }
+
+    // Phase 1: Rebuild Always
+    // DONE: we only need to compute when there are resource using Waged. We should
+    // do this as perf improvement in the future.
+    WagedInstanceCapacity capacityProvider = new WagedInstanceCapacity(dataProvider);
+    WagedResourceWeightsProvider weightProvider = new WagedResourceWeightsProvider(dataProvider);
+
+    // Process the currentState and update the available instance capacity.
+    capacityProvider.process(dataProvider, currentStateOutput, wagedEnabledResourceMap, weightProvider);
+    dataProvider.setWagedCapacityProviders(capacityProvider, weightProvider);
+  }
+
+  /**
+   * Function that checks whether we should return early, without any action on the capacity map or not.
+   * @param cache it is the cluster level cache for the resources.
+   * @param event the cluster event that is undergoing processing.
+   * @return true, of the condition evaluate to true and no action is needed, else false.
+   */
+  static boolean shouldNoOp(BaseControllerDataProvider cache, Map<String, Resource> resourceMap, ClusterEvent event) {
+    if (!(cache instanceof ResourceControllerDataProvider)) {
+      return true;
+    }
+
+    if (resourceMap == null || resourceMap.isEmpty()) {
+      return true;
+    }
+
+    ResourceControllerDataProvider dataProvider = (ResourceControllerDataProvider) cache;
+    if (Objects.isNull(dataProvider.getWagedInstanceCapacity())) {
+      return false;
+    }
+
+    switch (event.getEventType()) {
+      case TaskCurrentStateChange:
+      case MessageChange:

Review Comment:
   Updated the PR. Thanks for your review. :) 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


Re: [PR] [apache/helix] -- Fixes #2646 (Part-1), Optimize WagedInstanceCapacity Calculation to improve Helix Controller Pipeline [helix]

Posted by "junkaixue (via GitHub)" <gi...@apache.org>.
junkaixue commented on code in PR #2649:
URL: https://github.com/apache/helix/pull/2649#discussion_r1358956474


##########
helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/WagedInstanceCapacityManager.java:
##########
@@ -0,0 +1,119 @@
+package org.apache.helix.controller.rebalancer.waged;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
+import org.apache.helix.controller.dataproviders.BaseControllerDataProvider;
+import org.apache.helix.controller.dataproviders.ResourceControllerDataProvider;
+import org.apache.helix.controller.rebalancer.util.WagedValidationUtil;
+import org.apache.helix.controller.stages.AttributeName;
+import org.apache.helix.controller.stages.ClusterEvent;
+import org.apache.helix.controller.stages.CurrentStateOutput;
+import org.apache.helix.model.Resource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Manager class responsible for abstracting the management operations on the {@link WagedInstanceCapacity}
+ * cache such as rebuild and update operations on various scenarios.
+ */
+public class WagedInstanceCapacityManager {
+
+  private static final Logger LOG = LoggerFactory.getLogger(WagedInstanceCapacityManager.class);
+
+  private static class SingletonHelper {
+    private static final WagedInstanceCapacityManager INSTANCE = new WagedInstanceCapacityManager();
+  }
+
+  public static WagedInstanceCapacityManager getInstance() {
+    return SingletonHelper.INSTANCE;
+  }
+
+  public void processEvent(ClusterEvent event, CurrentStateOutput currentStateOutput) {
+    BaseControllerDataProvider cache = event.getAttribute(AttributeName.ControllerDataProvider.name());
+    final Map<String, Resource> resourceMap = event.getAttribute(AttributeName.RESOURCES.name());
+
+    if (shouldNoOp(cache, resourceMap, event)) {
+      return;
+    }
+
+    ResourceControllerDataProvider dataProvider = (ResourceControllerDataProvider) cache;
+    Map<String, Resource> wagedEnabledResourceMap = resourceMap.entrySet()
+        .stream()
+        .filter(entry -> WagedValidationUtil.isWagedEnabled(cache.getIdealState(entry.getKey())))
+        .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
+
+    if (wagedEnabledResourceMap.isEmpty()) {
+      return;
+    }
+
+    // Phase 1: Rebuild Always
+    // DONE: we only need to compute when there are resource using Waged. We should
+    // do this as perf improvement in the future.
+    WagedInstanceCapacity capacityProvider = new WagedInstanceCapacity(dataProvider);
+    WagedResourceWeightsProvider weightProvider = new WagedResourceWeightsProvider(dataProvider);
+
+    // Process the currentState and update the available instance capacity.
+    capacityProvider.process(dataProvider, currentStateOutput, wagedEnabledResourceMap, weightProvider);
+    dataProvider.setWagedCapacityProviders(capacityProvider, weightProvider);
+  }
+
+  /**
+   * Function that checks whether we should return early, without any action on the capacity map or not.
+   * @param cache it is the cluster level cache for the resources.
+   * @param event the cluster event that is undergoing processing.
+   * @return true, of the condition evaluate to true and no action is needed, else false.
+   */
+  static boolean shouldNoOp(BaseControllerDataProvider cache, Map<String, Resource> resourceMap, ClusterEvent event) {
+    if (!(cache instanceof ResourceControllerDataProvider)) {
+      return true;
+    }
+
+    if (resourceMap == null || resourceMap.isEmpty()) {
+      return true;
+    }
+
+    ResourceControllerDataProvider dataProvider = (ResourceControllerDataProvider) cache;
+    if (Objects.isNull(dataProvider.getWagedInstanceCapacity())) {
+      return false;
+    }
+
+    switch (event.getEventType()) {

Review Comment:
   This almost cover every thing... We don't need to have such filtering.



##########
helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/WagedInstanceCapacityManager.java:
##########
@@ -0,0 +1,119 @@
+package org.apache.helix.controller.rebalancer.waged;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
+import org.apache.helix.controller.dataproviders.BaseControllerDataProvider;
+import org.apache.helix.controller.dataproviders.ResourceControllerDataProvider;
+import org.apache.helix.controller.rebalancer.util.WagedValidationUtil;
+import org.apache.helix.controller.stages.AttributeName;
+import org.apache.helix.controller.stages.ClusterEvent;
+import org.apache.helix.controller.stages.CurrentStateOutput;
+import org.apache.helix.model.Resource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Manager class responsible for abstracting the management operations on the {@link WagedInstanceCapacity}
+ * cache such as rebuild and update operations on various scenarios.
+ */
+public class WagedInstanceCapacityManager {

Review Comment:
   Let's try to minimize class creation. I think we can have the Wagedcapacity in the cache. We don't have to build such manager.



##########
helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/WagedInstanceCapacity.java:
##########
@@ -130,28 +136,29 @@ public void processPendingMessages(ResourceControllerDataProvider cache,
     }
   }
 
-
-  private void processCurrentState(ResourceControllerDataProvider cache,
-      CurrentStateOutput currentStateOutput, Map<String, Resource> resourceMap,
-      WagedResourceWeightsProvider weightProvider) {
+  void processCurrentState(ResourceControllerDataProvider cache,
+      CurrentStateOutput currentStateOutput, Map<String, Resource> resourceMap) {
 
     // Iterate through all the resources
     for (Map.Entry<String, Resource> entry : resourceMap.entrySet()) {
       String resName = entry.getKey();
       Resource resource = entry.getValue();
 
-      // if Resource is WAGED managed, then we need to manage the capacity.
-      if (!WagedValidationUtil.isWagedEnabled(cache.getIdealState(resName))) {
-        continue;
-      }
-
       // list of partitions in the resource
       Collection<Partition> partitions = resource.getPartitions();
 
+      // calculate merge resource-config one for each resource.
+      ResourceConfig resourceConfig = cache.getResourceConfig(resName);
+      IdealState is = cache.getIdealState(resName);
+      ResourceConfig mergedResourceConfig =
+          ResourceConfig.mergeIdealStateWithResourceConfig(resourceConfig, is);

Review Comment:
   Why we merge here... Original design is because some config in IS should be stay with Resource Config. But even there is IS change event, I don't think we need to merge any change from IS to resource config. I don't get the merge operation here...



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


Re: [PR] [apache/helix] -- Fixes #2646 (Part-1), Optimize WagedInstanceCapacity Calculation to improve Helix Controller Pipeline [helix]

Posted by "junkaixue (via GitHub)" <gi...@apache.org>.
junkaixue commented on code in PR #2649:
URL: https://github.com/apache/helix/pull/2649#discussion_r1364621820


##########
helix-core/src/main/java/org/apache/helix/controller/stages/CurrentStateComputationStage.java:
##########
@@ -339,4 +333,61 @@ private void reportResourcePartitionCapacityMetrics(ExecutorService executorServ
       return null;
     });
   }
+
+  void handleResourceCapacityCalculation(ClusterEvent event, ResourceControllerDataProvider cache,
+      CurrentStateOutput currentStateOutput) {
+    Map<String, Resource> resourceMap = event.getAttribute(AttributeName.RESOURCES.name());
+    if (skipCapacityCalculation(cache, resourceMap, event)) {
+      return;
+    }
+
+    Map<String, Resource> wagedEnabledResourceMap = resourceMap.entrySet()
+        .stream()

Review Comment:
   We can do parallelStream() here.



##########
helix-core/src/main/java/org/apache/helix/controller/stages/CurrentStateComputationStage.java:
##########
@@ -339,4 +333,61 @@ private void reportResourcePartitionCapacityMetrics(ExecutorService executorServ
       return null;
     });
   }
+
+  void handleResourceCapacityCalculation(ClusterEvent event, ResourceControllerDataProvider cache,
+      CurrentStateOutput currentStateOutput) {
+    Map<String, Resource> resourceMap = event.getAttribute(AttributeName.RESOURCES.name());
+    if (skipCapacityCalculation(cache, resourceMap, event)) {
+      return;
+    }
+
+    Map<String, Resource> wagedEnabledResourceMap = resourceMap.entrySet()
+        .stream()
+        .filter(entry -> WagedValidationUtil.isWagedEnabled(cache.getIdealState(entry.getKey())))
+        .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
+
+    if (wagedEnabledResourceMap.isEmpty()) {
+      return;
+    }
+
+    // Phase 1: Rebuild Always
+    WagedInstanceCapacity capacityProvider = new WagedInstanceCapacity(cache);
+    WagedResourceWeightsProvider weightProvider = new WagedResourceWeightsProvider(cache);
+
+    capacityProvider.process(cache, currentStateOutput, wagedEnabledResourceMap, weightProvider);
+    cache.setWagedCapacityProviders(capacityProvider, weightProvider);
+  }
+
+  /**
+   * Function that checks whether we should return early, without any action on the capacity map or not.
+   *
+   * @param cache it is the cluster level cache for the resources.
+   * @param event the cluster event that is undergoing processing.
+   * @return true, of the condition evaluate to true and no action is needed, else false.
+   */
+  static boolean skipCapacityCalculation(ResourceControllerDataProvider cache, Map<String, Resource> resourceMap,
+      ClusterEvent event) {
+    if (resourceMap == null || resourceMap.isEmpty()) {
+      return true;
+    }
+
+    if (Objects.isNull(cache.getWagedInstanceCapacity())) {
+      return false;
+    }
+
+    switch (event.getEventType()) {
+      case ClusterConfigChange:
+      case InstanceConfigChange:
+      case ResourceConfigChange:
+      case ControllerChange:
+      case LiveInstanceChange:
+      case CurrentStateChange:
+      case PeriodicalRebalance:
+      case MessageChange:
+        return false;
+      default:
+        return true;
+    }
+  }

Review Comment:
   Let's skip this one. I think you already listed all the events.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


Re: [PR] [apache/helix] -- Fixes #2646 (Part-1), Optimize WagedInstanceCapacity Calculation to improve Helix Controller Pipeline [helix]

Posted by "himanshukandwal (via GitHub)" <gi...@apache.org>.
himanshukandwal commented on code in PR #2649:
URL: https://github.com/apache/helix/pull/2649#discussion_r1364615734


##########
helix-core/src/main/java/org/apache/helix/controller/rebalancer/waged/WagedInstanceCapacity.java:
##########
@@ -130,28 +136,29 @@ public void processPendingMessages(ResourceControllerDataProvider cache,
     }
   }
 
-
-  private void processCurrentState(ResourceControllerDataProvider cache,
-      CurrentStateOutput currentStateOutput, Map<String, Resource> resourceMap,
-      WagedResourceWeightsProvider weightProvider) {
+  void processCurrentState(ResourceControllerDataProvider cache,
+      CurrentStateOutput currentStateOutput, Map<String, Resource> resourceMap) {
 
     // Iterate through all the resources
     for (Map.Entry<String, Resource> entry : resourceMap.entrySet()) {
       String resName = entry.getKey();
       Resource resource = entry.getValue();
 
-      // if Resource is WAGED managed, then we need to manage the capacity.
-      if (!WagedValidationUtil.isWagedEnabled(cache.getIdealState(resName))) {
-        continue;
-      }
-
       // list of partitions in the resource
       Collection<Partition> partitions = resource.getPartitions();
 
+      // calculate merge resource-config one for each resource.
+      ResourceConfig resourceConfig = cache.getResourceConfig(resName);
+      IdealState is = cache.getIdealState(resName);
+      ResourceConfig mergedResourceConfig =
+          ResourceConfig.mergeIdealStateWithResourceConfig(resourceConfig, is);
+
       for (Partition partition : partitions) {
         String partitionName = partition.getPartitionName();
         // Get Partition Weight
-        Map<String, Integer> partCapacity = weightProvider.getPartitionWeights(resName, partitionName);
+        Map<String, Integer> partCapacity =
+            WagedRebalanceUtil.fetchCapacityUsage(partitionName, mergedResourceConfig, cache.getClusterConfig());

Review Comment:
   Yes, I have removed this.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org