Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,12 @@ public static ConfigChanges tuneTaskManagerMemory(
scalingSummaries, evaluatedMetrics.getVertexMetrics()),
config,
memBudget);
MemorySize newHeapSize =
determineNewSize(getUsage(HEAP_MEMORY_USED, globalMetrics), config, memBudget);
// Assign memory to the METASPACE before the HEAP to ensure all needed memory is provided
// to the METASPACE
MemorySize newMetaspaceSize =
determineNewSize(getUsage(METASPACE_MEMORY_USED, globalMetrics), config, memBudget);
MemorySize newHeapSize =
determineNewSize(getUsage(HEAP_MEMORY_USED, globalMetrics), config, memBudget);
MemorySize newManagedSize =
adjustManagedMemory(
getUsage(MANAGED_MEMORY_USED, globalMetrics),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,34 @@ jobVertex1, new ScalingSummary(50, 25, Map.of()),
TaskManagerOptions.TOTAL_PROCESS_MEMORY.key(),
"14172382822 bytes"));

// Test METASPACE when memory usage is so high that it could take all the memory
metrics = new EvaluatedMetrics(vertexMetrics, new HashMap<>(globalMetrics));
metrics.getGlobalMetrics()
.put(ScalingMetric.HEAP_MEMORY_USED, EvaluatedScalingMetric.avg(30812254720d));
// Set usage to max metaspace usage to ensure the calculation take in account max size
metrics.getGlobalMetrics()
.put(ScalingMetric.METASPACE_MEMORY_USED, EvaluatedScalingMetric.avg(268435456d));
configChanges =
MemoryTuning.tuneTaskManagerMemory(
context, metrics, jobTopology, scalingSummaries, eventHandler);
assertThat(configChanges.getOverrides())
.containsExactlyInAnyOrderEntriesOf(
Map.of(
TaskManagerOptions.MANAGED_MEMORY_FRACTION.key(),
"0.0",
TaskManagerOptions.NETWORK_MEMORY_MIN.key(),
"13760 kb",
TaskManagerOptions.NETWORK_MEMORY_MAX.key(),
"13760 kb",
TaskManagerOptions.JVM_METASPACE.key(),
"322122547 bytes",
TaskManagerOptions.JVM_OVERHEAD_FRACTION.key(),
"0.034",
TaskManagerOptions.FRAMEWORK_HEAP_MEMORY.key(),
"0 bytes",
TaskManagerOptions.TOTAL_PROCESS_MEMORY.key(),
"30 gb"));

// Test tuning disabled
config.set(AutoScalerOptions.MEMORY_TUNING_ENABLED, false);
assertThat(
Expand Down