Add a scoring-based approach to modifying packing plan #1572
Add a scoring-based approach to modifying packing plan #1572
Conversation
Any comments on this one? I think this change will make it much easier for us to compose rankings for how instance placement and removal should occur. |
@billonahill Will take a look later today |
package com.twitter.heron.packing.builder; | ||
|
||
/** | ||
* Sorts containers ascending by container id. Id firstId and maxId as passed, starte with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a typo: starte -> start
@@ -284,11 +285,13 @@ private void removeInstancesFromContainers(PackingPlanBuilder packingPlanBuilder | |||
ArrayList<RamRequirement> ramRequirements = | |||
getSortedRAMInstances(componentsToScaleDown.keySet()); | |||
|
|||
ContainerIdScorer scorer = new ContainerIdScorer(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is a reverse scorer for instance removal better? IMO, inserting and removing instances among the containers in reverse direct will result in better resource utilization.
@billonahill I have reviewed this PR. It is smart to use a scorer here. Great work! I have two comments:
Thanks. |
@wangli1426 thanks for the comments.
|
* @return containerId of the container the instance was removed from | ||
* @throws com.twitter.heron.spi.packing.PackingException if the instance could not be removed | ||
*/ | ||
public int removeInstance(List<Scorer<Container>> scorers, String componentName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the RCRR implementation, during scale down we do not always start from the first container. For example if we need to scale down 2 components by 1 instance from containers [1...5] and the first component is removed from instance 2 then the removal for the next component will start from container 3. This will help with load balancing. This remove instance method does not capture that. However, it is fine if a good scoring method is used when we change the scale down approach as discussed in the other thread.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@billonahill I'm not sure if that is the same. In the previous example if we pass as input to the constructor container id 3 and containrId 5 then the search will stop at 5, right? Wehat we ideally want is to start from 3 and use this sequence: 4,5,1,2. Is that behavior captured?
I believe we've captured that used case. See how we use the two different On Tue, Nov 22, 2016 at 11:02 AM avflor notifications@github.com wrote:
|
Yes, that's why the constructor requires the maxId, so it can loop back to On Tue, Nov 22, 2016 at 11:18 AM avflor notifications@github.com wrote:
|
@avflor @wangli1426 any other comments? |
@billionahill LGTM |
LGTM |
* Add a scoring-based approach to modifying packing plan * Also use the scoring approach for adding in FFDP * Added more unit tests are removed dead code * Fixed typo and added check for estimated new container size > 0 before increasing.
Instances are often added and removed to containers based on a ranking of all containers. This adds methods to the PackingPlanBuilder API to make it easy to do so without requiring the caller to rank, sort and iterate through containers. Instead, packing algorithms can now add/remove instances by passing a class that scores Components based on some heuristic. Multiple scorers can be passed for primary, secondary, tertiary, etc ranking.
This patch includes an common implementation that is used for round robin placement, but other custom implementations can be passed to score based on balance, resource utilization, etc.