From ad607a1d76b445f0d7e84c6b8add1a7d53217208 Mon Sep 17 00:00:00 2001 From: Viraj Jasani Date: Mon, 2 Dec 2019 11:12:27 +0530 Subject: [PATCH] HBASE-23335 : Improving cost functions array copy in StochasticLoadBalancer (#874) --- .../hbase/master/balancer/StochasticLoadBalancer.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java index 5ad32f6f0bb..911f8fea1bd 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java @@ -417,9 +417,7 @@ public class StochasticLoadBalancer extends BaseLoadBalancer { double currentCost = computeCost(cluster, Double.MAX_VALUE); curOverallCost = currentCost; - for (int i = 0; i < this.curFunctionCosts.length; i++) { - curFunctionCosts[i] = tempFunctionCosts[i]; - } + System.arraycopy(tempFunctionCosts, 0, curFunctionCosts, 0, curFunctionCosts.length); double initCost = currentCost; double newCost = currentCost; @@ -463,9 +461,7 @@ public class StochasticLoadBalancer extends BaseLoadBalancer { // save for JMX curOverallCost = currentCost; - for (int i = 0; i < this.curFunctionCosts.length; i++) { - curFunctionCosts[i] = tempFunctionCosts[i]; - } + System.arraycopy(tempFunctionCosts, 0, curFunctionCosts, 0, curFunctionCosts.length); } else { // Put things back the way they were before. // TODO: undo by remembering old values