YARN-4690. Skip object allocation in FSAppAttempt#getResourceUsage when possible (Ming Ma via sjlee)

(cherry picked from commit 7de70680fe)
This commit is contained in:
Sangjin Lee 2016-02-17 20:55:21 -08:00
parent 25c2597f9c
commit 23b5c71729
2 changed files with 9 additions and 1 deletions

View File

@ -2312,6 +2312,9 @@ Release 2.6.5 - UNRELEASED
OPTIMIZATIONS OPTIMIZATIONS
YARN-4690. Skip object allocation in FSAppAttempt#getResourceUsage when
possible (Ming Ma via sjlee)
BUG FIXES BUG FIXES
Release 2.6.4 - 2016-02-11 Release 2.6.4 - 2016-02-11

View File

@ -890,7 +890,12 @@ public Resource getMaxShare() {
public Resource getResourceUsage() { public Resource getResourceUsage() {
// Here the getPreemptedResources() always return zero, except in // Here the getPreemptedResources() always return zero, except in
// a preemption round // a preemption round
return Resources.subtract(getCurrentConsumption(), getPreemptedResources()); // In the common case where preempted resource is zero, return the
// current consumption Resource object directly without calling
// Resources.subtract which creates a new Resource object for each call.
return getPreemptedResources().equals(Resources.none()) ?
getCurrentConsumption() :
Resources.subtract(getCurrentConsumption(), getPreemptedResources());
} }
@Override @Override