From 5c387f8781a3d7ff280de6656393567f13038673 Mon Sep 17 00:00:00 2001 From: David Roberts Date: Fri, 18 Nov 2022 13:25:50 +0000 Subject: [PATCH] [ML] Fix incorrect assumption about minimum ML node size (#91694) (#91697) The ML autoscaling code was making an assumption that all ML nodes in Cloud will be at least 1GB. This is not correct. After allowing for logging and metrics collection it is possible for ML nodes to be smaller. This PR updates the assumption to 0.5GB. --- .../xpack/ml/utils/NativeMemoryCalculator.java | 2 +- .../ml/autoscaling/MlMemoryAutoscalingDeciderTests.java | 4 ++-- .../xpack/ml/utils/NativeMemoryCalculatorTests.java | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/utils/NativeMemoryCalculator.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/utils/NativeMemoryCalculator.java index bcf964281d32b..6964639f0535f 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/utils/NativeMemoryCalculator.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/utils/NativeMemoryCalculator.java @@ -34,7 +34,7 @@ public final class NativeMemoryCalculator { // Maximum permitted JVM heap size when auto-configured. // Must match the value used in MachineDependentHeap.MachineNodeRole.ML_ONLY. public static final long STATIC_JVM_UPPER_THRESHOLD = ByteSizeValue.ofGb(31).getBytes(); - public static final long MINIMUM_AUTOMATIC_NODE_SIZE = ByteSizeValue.ofGb(1).getBytes(); + public static final long MINIMUM_AUTOMATIC_NODE_SIZE = ByteSizeValue.ofMb(512).getBytes(); private static final long OS_OVERHEAD = ByteSizeValue.ofMb(200).getBytes(); // Memory size beyond which the JVM is given 10% of memory instead of 40%. // Must match the value used in MachineDependentHeap.MachineNodeRole.ML_ONLY. diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/autoscaling/MlMemoryAutoscalingDeciderTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/autoscaling/MlMemoryAutoscalingDeciderTests.java index c7a8028d80ce3..8e82c79d139c2 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/autoscaling/MlMemoryAutoscalingDeciderTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/autoscaling/MlMemoryAutoscalingDeciderTests.java @@ -1217,8 +1217,8 @@ public void testScale_WithNoMlNodesButWaitingAnalytics() { "requesting scale up as number of jobs in queues exceeded configured limit and there are no machine learning nodes" ) ); - assertThat(result.nodeSize(), equalTo(ByteSizeValue.ofGb(1))); - assertThat(result.tierSize(), equalTo(ByteSizeValue.ofGb(1))); + assertThat(result.nodeSize(), equalTo(ByteSizeValue.ofMb(714))); + assertThat(result.tierSize(), equalTo(ByteSizeValue.ofMb(714))); } private MlMemoryAutoscalingDecider buildDecider() { diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/utils/NativeMemoryCalculatorTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/utils/NativeMemoryCalculatorTests.java index c818152943953..907aec12217ed 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/utils/NativeMemoryCalculatorTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/utils/NativeMemoryCalculatorTests.java @@ -108,15 +108,15 @@ public void testConsistencyInAutoCalculation() { NativeMemoryCapacity nativeMemoryCapacity = new NativeMemoryCapacity(bytesForML, bytesForML, jvmSize); MlMemoryAutoscalingCapacity capacity = nativeMemoryCapacity.autoscalingCapacity(30, true, Long.MAX_VALUE, 1).build(); - // We don't allow node sizes below 1GB, so we will always be at least that large + // We don't allow node sizes below 0.5GB, so we will always be at least that large // Also, allow 1 byte off for weird rounding issues assertThat( capacity.nodeSize().getBytes(), - greaterThanOrEqualTo(Math.max(nodeSize, ByteSizeValue.ofGb(1).getBytes()) - 1L) + greaterThanOrEqualTo(Math.max(nodeSize, ByteSizeValue.ofMb(512).getBytes()) - 1L) ); assertThat( capacity.tierSize().getBytes(), - greaterThanOrEqualTo(Math.max(nodeSize, ByteSizeValue.ofGb(1).getBytes()) - 1L) + greaterThanOrEqualTo(Math.max(nodeSize, ByteSizeValue.ofMb(512).getBytes()) - 1L) ); } }