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 2019/08/22 22:54:57 UTC
[mesos] 02/02: Added ResourceQuantities::fromScalarResource.
This is an automated email from the ASF dual-hosted git repository.
bmahler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git
commit 05e5ca4b3446e34447f632463efe9a34b4bace7f
Author: Benjamin Mahler <bm...@apache.org>
AuthorDate: Thu Aug 22 17:42:57 2019 -0400
Added ResourceQuantities::fromScalarResource.
Master + previous patches:
*HierarchicalAllocator_WithQuotaParam.LargeAndSmallQuota/2
Made 3500 allocations in 24.15 secs
Made 0 allocation in 20.48 secs
Master + previous patches + this patch:
Master + this patch:
*HierarchicalAllocator_WithQuotaParam.LargeAndSmallQuota/2
Made 3500 allocations in 23.37 secs
Made 0 allocation in 19.72 secs
Review: https://reviews.apache.org/r/71354
---
include/mesos/resource_quantities.hpp | 4 ++++
src/common/resource_quantities.cpp | 13 +++++++++++++
src/common/resources_utils.cpp | 4 ++--
3 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/include/mesos/resource_quantities.hpp b/include/mesos/resource_quantities.hpp
index c861df8..cdb3427 100644
--- a/include/mesos/resource_quantities.hpp
+++ b/include/mesos/resource_quantities.hpp
@@ -83,6 +83,10 @@ public:
// be triggered.
static ResourceQuantities fromScalarResources(const Resources& resources);
+ // Same as above, but takes a single Resource that must be valid
+ // and of scalar type.
+ static ResourceQuantities fromScalarResource(const Resource& resource);
+
// Take `Resources` and combine them into `ResourceQuantities`. This function
// assumes that the provided resources have already been validated; for
// example, it assumes that ranges do not overlap and that sets do not contain
diff --git a/src/common/resource_quantities.cpp b/src/common/resource_quantities.cpp
index 9577181..7c7ede3 100644
--- a/src/common/resource_quantities.cpp
+++ b/src/common/resource_quantities.cpp
@@ -88,6 +88,19 @@ ResourceQuantities ResourceQuantities::fromScalarResources(
}
+ResourceQuantities ResourceQuantities::fromScalarResource(
+ const Resource& resource)
+{
+ ResourceQuantities result;
+
+ CHECK_EQ(Value::SCALAR, resource.type()) << " Resource: " << resource;
+
+ result.add(resource.name(), resource.scalar());
+
+ return result;
+}
+
+
ResourceQuantities ResourceQuantities::fromResources(const Resources& resources)
{
ResourceQuantities result;
diff --git a/src/common/resources_utils.cpp b/src/common/resources_utils.cpp
index 720b954..cbdad4b 100644
--- a/src/common/resources_utils.cpp
+++ b/src/common/resources_utils.cpp
@@ -929,7 +929,7 @@ Resources shrinkResources(const Resources& resources, ResourceQuantities target)
CHECK_EQ(Value::SCALAR, resource.type()) << " Resources: " << resources;
if (Resources::shrink(&resource, scalar)) {
- target -= ResourceQuantities::fromScalarResources(resource);
+ target -= ResourceQuantities::fromScalarResource(resource);
result += std::move(resource);
}
}
@@ -963,7 +963,7 @@ Resources shrinkResources(const Resources& resources, ResourceLimits target)
CHECK_EQ(Value::SCALAR, resource.type()) << " Resources: " << resources;
if (Resources::shrink(&resource, *limit)) {
- target -= ResourceQuantities::fromScalarResources(resource);
+ target -= ResourceQuantities::fromScalarResource(resource);
result += std::move(resource);
}
}