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 2018/08/02 00:28:15 UTC

mesos git commit: Avoided some expensive copies in the allocator.

Repository: mesos
Updated Branches:
  refs/heads/master b1381f427 -> 9457dce1d


Avoided some expensive copies in the allocator.

Avoided unnecessary copies from
`sorter->allocation(string client)` calls.

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


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

Branch: refs/heads/master
Commit: 9457dce1d99b5616d1b5eeb9a344733f6320d7b5
Parents: b1381f4
Author: Meng Zhu <mz...@mesosphere.io>
Authored: Wed Aug 1 17:27:58 2018 -0700
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Wed Aug 1 17:27:58 2018 -0700

----------------------------------------------------------------------
 src/master/allocator/mesos/hierarchical.cpp | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/9457dce1/src/master/allocator/mesos/hierarchical.cpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/mesos/hierarchical.cpp b/src/master/allocator/mesos/hierarchical.cpp
index d7f073d..0b13d04 100644
--- a/src/master/allocator/mesos/hierarchical.cpp
+++ b/src/master/allocator/mesos/hierarchical.cpp
@@ -1409,9 +1409,10 @@ void HierarchicalAllocatorProcess::setQuota(
 
   // Copy allocation information for the quota'ed role.
   if (roleSorter->contains(role)) {
-    hashmap<SlaveID, Resources> roleAllocation = roleSorter->allocation(role);
     foreachpair (
-        const SlaveID& slaveId, const Resources& resources, roleAllocation) {
+        const SlaveID& slaveId,
+        const Resources& resources,
+        roleSorter->allocation(role)) {
       // See comment at `quotaRoleSorter` declaration regarding non-revocable.
       quotaRoleSorter->allocated(role, slaveId, resources.nonRevocable());
     }
@@ -1697,10 +1698,8 @@ void HierarchicalAllocatorProcess::__allocate()
       getQuotaRoleAllocatedScalarQuantities(role);
 
     // Lastly subtract allocated reservations on each agent.
-    const hashmap<SlaveID, Resources> allocations =
-      quotaRoleSorter->allocation(role);
-
-    foreachvalue (const Resources& resources, allocations) {
+    foreachvalue (
+        const Resources& resources, quotaRoleSorter->allocation(role)) {
       rolesConsumedQuotaScalarQuantites[role] -=
         resources.reserved().createStrippedScalarQuantity();
     }
@@ -1749,16 +1748,16 @@ void HierarchicalAllocatorProcess::__allocate()
   // we cannot simply loop over the reservations' roles.
   Resources totalAllocatedReservationScalarQuantities;
   foreachkey (const string& role, roles) {
-    hashmap<SlaveID, Resources> allocations;
+    const hashmap<SlaveID, Resources>* allocations;
     if (quotaRoleSorter->contains(role)) {
-      allocations = quotaRoleSorter->allocation(role);
+      allocations = &quotaRoleSorter->allocation(role);
     } else if (roleSorter->contains(role)) {
-      allocations = roleSorter->allocation(role);
+      allocations = &roleSorter->allocation(role);
     } else {
       continue; // This role has no allocation.
     }
 
-    foreachvalue (const Resources& resources, allocations) {
+    foreachvalue (const Resources& resources, *CHECK_NOTNULL(allocations)) {
       totalAllocatedReservationScalarQuantities +=
         resources.reserved().createStrippedScalarQuantity();
     }