Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shuffle tasks on hosts with overutilized memory resources #1937

Merged
merged 21 commits into from
May 22, 2019
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Also collect a list of mem-overloaded slaves.
baconmania committed May 8, 2019
commit 82644f762ce052a9d0f288a273c400f66fe7a076
Original file line number Diff line number Diff line change
@@ -101,6 +101,7 @@ public void collectSlaveUsage(
Map<String, RequestUtilization> utilizationPerRequestId,
Map<String, RequestUtilization> previousUtilizations,
Map<SingularitySlaveUsage, List<TaskIdWithUsage>> overLoadedHosts,
Map<SingularitySlaveUsage, List<TaskIdWithUsage>> highMemUsageHosts,
AtomicLong totalMemBytesUsed,
AtomicLong totalMemBytesAvailable,
AtomicDouble totalCpuUsed,
@@ -157,6 +158,7 @@ public void collectSlaveUsage(
}

boolean slaveOverloaded = systemCpusTotal > 0 && systemLoad / systemCpusTotal > 1.0;
boolean slaveExperiencingHighMemUsage = ((systemMemTotalBytes - systemMemFreeBytes) / systemMemTotalBytes) > configuration.getShuffleTasksWhenSlaveMemoryUtilizationPercentageExceeds();
List<TaskIdWithUsage> possibleTasksToShuffle = new ArrayList<>();

for (MesosTaskMonitorObject taskUsage : allTaskUsage) {
@@ -216,11 +218,11 @@ public void collectSlaveUsage(
cpusUsedOnSlave += taskCpusUsed;
}

if (configuration.isShuffleTasksForOverloadedSlaves() && currentUsage != null && currentUsage.getCpusUsed() > 0) {
if (currentUsage != null && currentUsage.getCpusUsed() > 0) {
if (isEligibleForShuffle(task)) {
Optional<SingularityTaskHistoryUpdate> maybeCleanupUpdate = taskManager.getTaskHistoryUpdate(task, ExtendedTaskState.TASK_CLEANING);
if (maybeCleanupUpdate.isPresent() && isTaskAlreadyCleanedUpForShuffle(maybeCleanupUpdate.get())) {
LOG.trace("Task {} already being cleaned up to spread cpu usage, skipping", taskId);
LOG.trace("Task {} already being cleaned up to spread cpu or mem usage, skipping", taskId);
} else {
if (maybeResources.isPresent()) {
possibleTasksToShuffle.add(new TaskIdWithUsage(task, maybeResources.get(), currentUsage));
@@ -248,6 +250,10 @@ public void collectSlaveUsage(
overLoadedHosts.put(slaveUsage, possibleTasksToShuffle);
}

if (slaveExperiencingHighMemUsage) {
highMemUsageHosts.put(slaveUsage, possibleTasksToShuffle);
}

if (slaveUsage.getMemoryBytesTotal().isPresent() && slaveUsage.getCpusTotal().isPresent()) {
totalMemBytesUsed.getAndAdd((long) slaveUsage.getMemoryBytesUsed());
totalCpuUsed.getAndAdd(slaveUsage.getCpusUsed());