Skip to content

Commit

Permalink
Merge pull request #23574 from vespa-engine/bratseth/autoscale-faster-2
Browse files Browse the repository at this point in the history
Bratseth/autoscale faster 2
  • Loading branch information
freva authored Aug 3, 2022
2 parents fd8261f + ec4f383 commit 8844e68
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ public AllocationOptimizer(NodeRepository nodeRepository) {
}

/**
* Searches the space of possible allocations given a target
* Searches the space of possible allocations given a target relative load
* and (optionally) cluster limits and returns the best alternative.
*
* @return the best allocation, if there are any possible legal allocations, fulfilling the target
* fully or partially, within the limits
*/
public Optional<AllocatableClusterResources> findBestAllocation(ResourceTarget target,
public Optional<AllocatableClusterResources> findBestAllocation(Load targetLoad,
AllocatableClusterResources current,
ClusterModel clusterModel,
Limits limits) {
Expand All @@ -51,7 +51,7 @@ public Optional<AllocatableClusterResources> findBestAllocation(ResourceTarget t
ClusterResources next = new ClusterResources(nodes,
groups,
nodeResourcesWith(nodes, groups,
limits, target, current, clusterModel));
limits, targetLoad, current, clusterModel));
var allocatableResources = AllocatableClusterResources.from(next, current.clusterSpec(), limits,
hosts, nodeRepository);
if (allocatableResources.isEmpty()) continue;
Expand All @@ -64,16 +64,19 @@ public Optional<AllocatableClusterResources> findBestAllocation(ResourceTarget t

/**
* For the observed load this instance is initialized with, returns the resources needed per node to be at
* ideal load given a target node count
* the target relative load, given a target node and group count.
*/
private NodeResources nodeResourcesWith(int nodes,
int groups,
Limits limits,
ResourceTarget target,
Load targetLoad,
AllocatableClusterResources current,
ClusterModel clusterModel) {
var scaled = clusterModel.loadWith(nodes, groups)
.scaled(Load.one().divide(clusterModel.redundancyAdjustment()).scaled(target.resources()));
var scaled = targetLoad // redundancy aware target relative to current load
.multiply(clusterModel.loadWith(nodes, groups)) // redundancy aware adjustment with these counts
.divide(clusterModel.redundancyAdjustment()) // correct for double redundancy adjustment
.scaled(current.realResources().nodeResources());

// Combine the scaled resource values computed here
// with the currently configured non-scaled values, given in the limits, if any
var nonScaled = limits.isEmpty() || limits.min().nodeResources().isUnspecified()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,8 @@ private Advice autoscale(Application application, Cluster cluster, NodeList clus
" nodes, but require from " + clusterNodes.size());

var currentAllocation = new AllocatableClusterResources(clusterNodes.asList(), nodeRepository);
var target = ResourceTarget.idealLoad(clusterModel, currentAllocation);

Optional<AllocatableClusterResources> bestAllocation =
allocationOptimizer.findBestAllocation(target, currentAllocation, clusterModel, limits);
allocationOptimizer.findBestAllocation(clusterModel.loadAdjustment(), currentAllocation, clusterModel, limits);
if (bestAllocation.isEmpty())
return Advice.dontScale(Status.insufficient, "No allocations are possible within configured limits");

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import com.yahoo.vespa.hosted.provision.autoscale.AllocationOptimizer;
import com.yahoo.vespa.hosted.provision.autoscale.ClusterModel;
import com.yahoo.vespa.hosted.provision.autoscale.Limits;
import com.yahoo.vespa.hosted.provision.autoscale.ResourceTarget;
import com.yahoo.vespa.hosted.provision.autoscale.Load;
import com.yahoo.vespa.hosted.provision.node.Allocation;
import com.yahoo.vespa.hosted.provision.node.filter.ApplicationFilter;
import com.yahoo.vespa.hosted.provision.node.filter.NodeHostFilter;
Expand Down Expand Up @@ -196,7 +196,7 @@ private ClusterResources within(Limits limits,
if (! firstDeployment && currentAsAdvertised.isWithin(limits.min(), limits.max())) return currentAsAdvertised;

// Otherwise, find an allocation that preserves the current resources as well as possible
return allocationOptimizer.findBestAllocation(ResourceTarget.preserve(clusterModel, current),
return allocationOptimizer.findBestAllocation(Load.one(),
current,
clusterModel,
limits)
Expand Down

0 comments on commit 8844e68

Please sign in to comment.