From e9c4e69f619cac2399965473aedbfd642ced469a Mon Sep 17 00:00:00 2001 From: Jon Bratseth Date: Tue, 25 Jul 2023 11:39:00 +0200 Subject: Cleanup --- .../hosted/provision/autoscale/AllocationOptimizer.java | 13 +++---------- .../vespa/hosted/provision/autoscale/ClusterModel.java | 8 ++++++++ 2 files changed, 11 insertions(+), 10 deletions(-) (limited to 'node-repository') diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/AllocationOptimizer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/AllocationOptimizer.java index bbce0442e19..7029991d7bf 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/AllocationOptimizer.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/AllocationOptimizer.java @@ -90,12 +90,9 @@ public class AllocationOptimizer { Load loadAdjustment, AllocatableClusterResources current, ClusterModel clusterModel) { - var loadWithTarget = loadAdjustment // redundancy adjusted target relative to current load - .multiply(clusterModel.loadWith(nodes, groups)) // redundancy aware adjustment with these counts - .divide(clusterModel.redundancyAdjustment()); // correct for double redundancy adjustment + var loadWithTarget = clusterModel.loadAdjustmentWith(nodes, groups, loadAdjustment); - // Don't scale down all the way to the ideal as that leaves no headroom before needing to scale back up - var oldLoad = loadWithTarget; + // Leave some headroom above the ideal allocation to avoid immediately needing to scale back up if (loadAdjustment.cpu() < 1 && (1.0 - loadWithTarget.cpu()) < headroomRequiredToScaleDown) loadAdjustment = loadAdjustment.withCpu(1.0); if (loadAdjustment.memory() < 1 && (1.0 - loadWithTarget.memory()) < headroomRequiredToScaleDown) @@ -103,11 +100,7 @@ public class AllocationOptimizer { if (loadAdjustment.disk() < 1 && (1.0 - loadWithTarget.disk()) < headroomRequiredToScaleDown) loadAdjustment = loadAdjustment.withDisk(1.0); - loadWithTarget = loadAdjustment // redundancy adjusted target relative to current load - .multiply(clusterModel.loadWith(nodes, groups)) // redundancy aware adjustment with these counts - .divide(clusterModel.redundancyAdjustment()); // correct for double redundancy adjustment - - System.out.println(nodes + " nodes, headroom adjust: " + oldLoad + " -> " + loadWithTarget); + loadWithTarget = clusterModel.loadAdjustmentWith(nodes, groups, loadAdjustment); var scaled = loadWithTarget.scaled(current.realResources().nodeResources()); var nonScaled = limits.isEmpty() || limits.min().nodeResources().isUnspecified() diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/ClusterModel.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/ClusterModel.java index 61f3dc57d31..0d64d4fbb10 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/ClusterModel.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/ClusterModel.java @@ -171,6 +171,14 @@ public class ClusterModel { return Duration.ofMinutes(5); } + /** Transforms the given load adjustment to an equivalent adjustment given a target number of nodes and groups. */ + public Load loadAdjustmentWith(int nodes, int groups, Load loadAdjustment) { + return loadAdjustment // redundancy adjusted target relative to current load + .multiply(loadWith(nodes, groups)) // redundancy aware adjustment with these counts + .divide(redundancyAdjustment()); // correct for double redundancy adjustment + } + + /** * Returns the relative load adjustment accounting for redundancy given these nodes+groups * relative to node nodes+groups in this. -- cgit v1.2.3