hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vvasu...@apache.org
Subject [15/50] [abbrv] hadoop git commit: YARN-5969. FairShareComparator: Cache value of getResourceUsage for better performance. (zhangshilong via kasha)
Date Wed, 04 Jan 2017 08:03:49 GMT
YARN-5969. FairShareComparator: Cache value of getResourceUsage for better performance. (zhangshilong
via kasha)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/c3973e70
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/c3973e70
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/c3973e70

Branch: refs/heads/YARN-5673
Commit: c3973e7080bf71b57ace4a6adf4bb43f3c5d35b5
Parents: c0e0ef2
Author: Karthik Kambatla <kasha@cloudera.com>
Authored: Tue Dec 27 12:30:35 2016 -0800
Committer: Karthik Kambatla <kasha@cloudera.com>
Committed: Tue Dec 27 12:30:35 2016 -0800

----------------------------------------------------------------------
 .../scheduler/fair/policies/FairSharePolicy.java | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/c3973e70/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/policies/FairSharePolicy.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/policies/FairSharePolicy.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/policies/FairSharePolicy.java
index f120f0f..d47ea07 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/policies/FairSharePolicy.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/policies/FairSharePolicy.java
@@ -79,29 +79,32 @@ public class FairSharePolicy extends SchedulingPolicy {
       double minShareRatio1, minShareRatio2;
       double useToWeightRatio1, useToWeightRatio2;
       double weight1, weight2;
+      //Do not repeat the getResourceUsage calculation
+      Resource resourceUsage1 = s1.getResourceUsage();
+      Resource resourceUsage2 = s2.getResourceUsage();
       Resource minShare1 = Resources.min(RESOURCE_CALCULATOR, null,
           s1.getMinShare(), s1.getDemand());
       Resource minShare2 = Resources.min(RESOURCE_CALCULATOR, null,
           s2.getMinShare(), s2.getDemand());
       boolean s1Needy = Resources.lessThan(RESOURCE_CALCULATOR, null,
-          s1.getResourceUsage(), minShare1);
+          resourceUsage1, minShare1);
       boolean s2Needy = Resources.lessThan(RESOURCE_CALCULATOR, null,
-          s2.getResourceUsage(), minShare2);
-      minShareRatio1 = (double) s1.getResourceUsage().getMemorySize()
+          resourceUsage2, minShare2);
+      minShareRatio1 = (double) resourceUsage1.getMemorySize()
           / Resources.max(RESOURCE_CALCULATOR, null, minShare1, ONE).getMemorySize();
-      minShareRatio2 = (double) s2.getResourceUsage().getMemorySize()
+      minShareRatio2 = (double) resourceUsage2.getMemorySize()
           / Resources.max(RESOURCE_CALCULATOR, null, minShare2, ONE).getMemorySize();
 
       weight1 = s1.getWeights().getWeight(ResourceType.MEMORY);
       weight2 = s2.getWeights().getWeight(ResourceType.MEMORY);
       if (weight1 > 0.0 && weight2 > 0.0) {
-        useToWeightRatio1 = s1.getResourceUsage().getMemorySize() / weight1;
-        useToWeightRatio2 = s2.getResourceUsage().getMemorySize() / weight2;
+        useToWeightRatio1 = resourceUsage1.getMemorySize() / weight1;
+        useToWeightRatio2 = resourceUsage2.getMemorySize() / weight2;
       } else { // Either weight1 or weight2 equals to 0
         if (weight1 == weight2) {
           // If they have same weight, just compare usage
-          useToWeightRatio1 = s1.getResourceUsage().getMemorySize();
-          useToWeightRatio2 = s2.getResourceUsage().getMemorySize();
+          useToWeightRatio1 = resourceUsage1.getMemorySize();
+          useToWeightRatio2 = resourceUsage2.getMemorySize();
         } else {
           // By setting useToWeightRatios to negative weights, we give the
           // zero-weight one less priority, so the non-zero weight one will


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message