-
Notifications
You must be signed in to change notification settings - Fork 24.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML] Add effective max model memory limit to ML info (#55529)
The ML info endpoint returns the max_model_memory_limit setting if one is configured. However, it is still possible to create a job that cannot run anywhere in the current cluster because no node in the cluster has enough memory to accommodate it. This change adds an extra piece of information, limits.effective_max_model_memory_limit, to the ML info response that returns the biggest model memory limit that could be run in the current cluster assuming no other jobs were running. The idea is that the ML UI will be able to warn users who try to create jobs with higher model memory limits that their jobs will not be able to start unless they add a bigger ML node to their cluster. Relates elastic/kibana#63942
- Loading branch information
1 parent
4e8235f
commit d1a9b3a
Showing
4 changed files
with
156 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
...plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/TransportMlInfoActionTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.ml.action; | ||
|
||
import org.elasticsearch.Version; | ||
import org.elasticsearch.cluster.node.DiscoveryNode; | ||
import org.elasticsearch.cluster.node.DiscoveryNodes; | ||
import org.elasticsearch.common.transport.TransportAddress; | ||
import org.elasticsearch.common.unit.ByteSizeValue; | ||
import org.elasticsearch.test.ESTestCase; | ||
import org.elasticsearch.xpack.core.ml.dataframe.DataFrameAnalyticsConfig; | ||
import org.elasticsearch.xpack.core.ml.job.config.Job; | ||
import org.elasticsearch.xpack.ml.MachineLearning; | ||
|
||
import java.net.InetAddress; | ||
import java.util.Collections; | ||
|
||
import static org.hamcrest.Matchers.lessThanOrEqualTo; | ||
import static org.hamcrest.Matchers.notNullValue; | ||
import static org.hamcrest.Matchers.nullValue; | ||
|
||
public class TransportMlInfoActionTests extends ESTestCase { | ||
|
||
public void testCalculateEffectiveMaxModelMemoryLimit() { | ||
|
||
int mlMemoryPercent = randomIntBetween(5, 90); | ||
long highestMlMachineMemory = -1; | ||
|
||
DiscoveryNodes.Builder builder = DiscoveryNodes.builder(); | ||
for (int i = randomIntBetween(1, 10); i > 0; --i) { | ||
String nodeName = "_node_name" + i; | ||
String nodeId = "_node_id" + i; | ||
TransportAddress ta = new TransportAddress(InetAddress.getLoopbackAddress(), 9300 + i); | ||
if (randomBoolean()) { | ||
// Not an ML node | ||
builder.add(new DiscoveryNode(nodeName, nodeId, ta, Collections.emptyMap(), Collections.emptySet(), Version.CURRENT)); | ||
} else { | ||
// ML node | ||
long machineMemory = randomLongBetween(2000000000L, 100000000000L); | ||
highestMlMachineMemory = Math.max(machineMemory, highestMlMachineMemory); | ||
builder.add(new DiscoveryNode(nodeName, nodeId, ta, | ||
Collections.singletonMap(MachineLearning.MACHINE_MEMORY_NODE_ATTR, String.valueOf(machineMemory)), | ||
Collections.emptySet(), Version.CURRENT)); | ||
} | ||
} | ||
DiscoveryNodes nodes = builder.build(); | ||
|
||
ByteSizeValue effectiveMaxModelMemoryLimit = | ||
TransportMlInfoAction.calculateEffectiveMaxModelMemoryLimit(mlMemoryPercent, nodes); | ||
|
||
if (highestMlMachineMemory < 0) { | ||
assertThat(effectiveMaxModelMemoryLimit, nullValue()); | ||
} else { | ||
assertThat(effectiveMaxModelMemoryLimit, notNullValue()); | ||
assertThat(effectiveMaxModelMemoryLimit.getBytes() | ||
+ Math.max(Job.PROCESS_MEMORY_OVERHEAD.getBytes(), DataFrameAnalyticsConfig.PROCESS_MEMORY_OVERHEAD.getBytes()) | ||
+ MachineLearning.NATIVE_EXECUTABLE_CODE_OVERHEAD.getBytes(), | ||
lessThanOrEqualTo(highestMlMachineMemory * mlMemoryPercent / 100)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters