From 03c311eae3ad591630a452921172a4406dbda181 Mon Sep 17 00:00:00 2001 From: yufei Date: Tue, 21 Nov 2017 10:33:34 -0800 Subject: [PATCH] YARN-7513. Remove the scheduler lock in FSAppAttempt.getWeight() (Contributed by Wilfred Spiegelenburg) --- .../scheduler/fair/FSAppAttempt.java | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) 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/FSAppAttempt.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/FSAppAttempt.java index 94991ebb14..e711229bc4 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/FSAppAttempt.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/FSAppAttempt.java @@ -1304,20 +1304,14 @@ public Resource getResourceUsage() { @Override public float getWeight() { - double weight = 1.0; + float weight = 1.0F; if (scheduler.isSizeBasedWeight()) { - scheduler.getSchedulerReadLock().lock(); - - try { - // Set weight based on current memory demand - weight = Math.log1p(getDemand().getMemorySize()) / Math.log(2); - } finally { - scheduler.getSchedulerReadLock().unlock(); - } + // Set weight based on current memory demand + weight = (float)(Math.log1p(demand.getMemorySize()) / Math.log(2)); } - return (float)weight * this.getPriority().getPriority(); + return weight * appPriority.getPriority(); } @Override