[ 
https://issues.apache.org/jira/browse/YARN-4945?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15475092#comment-15475092
 ] 

Wangda Tan commented on YARN-4945:
----------------------------------

Thanks [~sunilg], 

Comments for v0:

*AbstractPreemptableResourceCalculator:*
- priorityBasedPolicy should not be a part of this class
- getMostUnderservedQueues/resetCapacity/isReservedPreemptionCandidatesSelector 
should be private
- TAComparator, move to IntraQueueCalculator

*Configuration:*
- USED_CAPACITY_THRESHOLD_FOR_PREEMPTION, it should be something like 
MAX_IGNORED_OVER_CAPACITY_FOR_INTRA_QUEUE for consistency? If you agree, all 
related fields, such as 
CapacitySchedulerPreemptionContext#getUsedCapThresholdForPreemptionPerQueue 
should be updated.

*IntraQueuePreemptableResourceCalculator & IntraQueueCandidatesSelector:*

The biggest issue I can see is: the logic is incompleted for calculator: 
we should include all ideal-allocation/preemptable resource calculation in this 
class, I found many of them are in PriorityIntraQueuePreemptionPolicy, such as: 
getResourceDemandFromAppsPerQueue.
In addition, the calculation of ideal-allocation & preemptable resource is also 
incomplete: for the v0 patch, it computed resource-to-obtain for intra-queue 
preemption, and preempt from the least straved app. This is not correct for 
future policies, for example, fairness policy can have a minimum resource 
allocated to each application, existing logic will preempt all containers from 
the application with maximum fair sharing.

So to make the logic to be complete, the 
IntraQueuePreemptableResourceCalculator should be:
1) Inter-queue preemptable resource will be calculated, it could be computed by 
IntraQueueCalculator or previous calculator
2) In each leaf queue, according to intra-queue preemption quota and other 
queue status, such as queue-policy, decide ideal-allocation and how much to 
preempt for each app
3) And we need to deduct selected resource for both queue/app (and even for 
user).

For example, preemptable resource calculation for priority will be:
{code} 
For each partition:

Q.unallocated = Q.used - Q.selected;

# initially, app.ideal = 0

# From highest priority to lowest priority app to calculate ideal
for app in sorted-by(priority):
    if Q.unallocated < 0:
        break;

        app.ideal = max(Q.unallocated, app.used + app.pending - app.selected)
        Q.unallocated -= app.ideal

# Intra queue preemptable quota
intra_q_preemptable = Q.maximum-preemptable - selected

# For lowest prioity to highest priority to calculate preemptable
for app in reserve-sorted-by(priority):
    if intra_q_preemptable < 0:
        break;
    app.preemptable = min(max(app.used - app.selected - app.ideal, 0), 
intra_q_preemptable)
    intra_q_preemptable -= app.preemptable
{code}

Some additional notes for the pesudo code above:
- Fairness policy need different logic to calculate ideal and preemptable, 
which similar to Algorithm 2 described in: 
https://www2.eecs.berkeley.edu/Pubs/TechRpts/2009/EECS-2009-55.pdf
- If we need to consider user-limit, we should deduct user.selected as well

Responsibility of calculator should be 1)-3), after that, select will decide 
what to preempt from each app. Of course, we will skip already selected 
containers while selecting intra-queue to-preempt containers.

*Unit test*
I found the TestProportionalCapacityPreemptionPolicyForIntraQueue uses 
duplicated logic from TestProportionalCapacityPreemptionPolicy, instead, could 
you take a look at ProportionalCapacityPreemptionPolicyMockFramework, which is 
used by TestProportionalCapacityPreemptionPolicyForReservedContainers and 
TestProportionalCapacityPreemptionPolicyForNodePartitions. You will be easily 
mock intra-queue preemption scenario with the new test framework.

> [Umbrella] Capacity Scheduler Preemption Within a queue
> -------------------------------------------------------
>
>                 Key: YARN-4945
>                 URL: https://issues.apache.org/jira/browse/YARN-4945
>             Project: Hadoop YARN
>          Issue Type: Bug
>            Reporter: Wangda Tan
>         Attachments: Intra-Queue Preemption Use Cases.pdf, 
> IntraQueuepreemption-CapacityScheduler (Design).pdf, YARN-2009-wip.2.patch, 
> YARN-2009-wip.patch, YARN-2009-wip.v3.patch, YARN-2009.v0.patch
>
>
> This is umbrella ticket to track efforts of preemption within a queue to 
> support features like:
> YARN-2009. YARN-2113. YARN-4781.



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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to