You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2016/08/11 00:46:39 UTC

mesos git commit: Avoid unnecessarily subtracting resources during contains check.

Repository: mesos
Updated Branches:
  refs/heads/master 853869eb3 -> 7ec00915d


Avoid unnecessarily subtracting resources during contains check.

In Resources::contains, we do not need to subtract resources if
the resource is not a persistent volume as other Resource objects
will be merged together into single Resource ojects.

This fix is adding persistent volume check before subtracting
resources, so that normal resources will not be subtracted. This
is a performance improvement.

Review: https://reviews.apache.org/r/50878/


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

Branch: refs/heads/master
Commit: 7ec00915d722b8f89ca4bb1b67afab5c3dd7cc9f
Parents: 853869e
Author: Guangya Liu <gy...@gmail.com>
Authored: Wed Aug 10 17:44:04 2016 -0700
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Wed Aug 10 17:44:04 2016 -0700

----------------------------------------------------------------------
 src/common/resources.cpp | 4 +++-
 src/v1/resources.cpp     | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/7ec00915/src/common/resources.cpp
----------------------------------------------------------------------
diff --git a/src/common/resources.cpp b/src/common/resources.cpp
index 2470c02..6b7af91 100644
--- a/src/common/resources.cpp
+++ b/src/common/resources.cpp
@@ -954,7 +954,9 @@ bool Resources::contains(const Resources& that) const
       return false;
     }
 
-    remaining.subtract(resource_);
+    if (isPersistentVolume(resource_.resource)) {
+      remaining.subtract(resource_);
+    }
   }
 
   return true;

http://git-wip-us.apache.org/repos/asf/mesos/blob/7ec00915/src/v1/resources.cpp
----------------------------------------------------------------------
diff --git a/src/v1/resources.cpp b/src/v1/resources.cpp
index 6c4e3b2..03ee0cb 100644
--- a/src/v1/resources.cpp
+++ b/src/v1/resources.cpp
@@ -957,7 +957,9 @@ bool Resources::contains(const Resources& that) const
       return false;
     }
 
-    remaining.subtract(resource_);
+    if (isPersistentVolume(resource_.resource)) {
+      remaining.subtract(resource_);
+    }
   }
 
   return true;