Qian Zhang created MESOS-3244:
---------------------------------

             Summary: Enhancement for the allocator() method in the default DRF 
allocator
                 Key: MESOS-3244
                 URL: https://issues.apache.org/jira/browse/MESOS-3244
             Project: Mesos
          Issue Type: Improvement
          Components: allocation
            Reporter: Qian Zhang
            Assignee: Qian Zhang
            Priority: Minor


In the method *HierarchicalAllocatorProcess::allocate(const hashset<SlaveID>& 
slaveIds)*, I see the following code:
{code}
template <class RoleSorter, class FrameworkSorter>
void
HierarchicalAllocatorProcess<RoleSorter, FrameworkSorter>::allocate(
    const hashset<SlaveID>& slaveIds_)
{
  ...
  foreach (const SlaveID& slaveId, slaveIds) {
    ...
    foreach (const std::string& role, roleSorter->sort()) {
      foreach (const std::string& frameworkId_, frameworkSorters[role]->sort()) 
{
        FrameworkID frameworkId;
        frameworkId.set_value(frameworkId_);

        // Calculate the currently available resources on the slave.
        Resources available = slaves[slaveId].total - slaves[slaveId].allocated;

        // NOTE: Currently, frameworks are allowed to have '*' role.
        // Calling reserved('*') returns an empty Resources object.
        Resources resources = available.unreserved() + available.reserved(role);
        ...
      }
    }
  }
}
{code}

My question is why the following two lines are put in the innermost loop (the 
3rd level foreach for framework).
{code}
        Resources available = slaves[slaveId].total - slaves[slaveId].allocated;
        Resources resources = available.unreserved() + available.reserved(role);
{code}
I think these two line has nothing to do with framework (they calculate 
available resources ONLY based on slave and role), but since they are in the 
innermost loop, they will be executed for EVERY framework of a role (imagine we 
have thousand frameworks for a role), but I think they should be only executed 
once for a role.

So I would suggest to move these two lines up, they should be in the 2nd level 
loop (the foreach loop for role), and in the 3rd level loop, for each framework 
of the role, we should directly use the result of these two lines rather than 
do the calculation for each framework.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to