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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better task balancing #1482

Merged
merged 73 commits into from Jun 8, 2017
Commits
Jump to file or symbol
Failed to load files and symbols.
+12 鈭12
Diff settings

Always

Just for now

Viewing a subset of changes. View all

use free space on slave in task balancing

  • Loading branch information...
darcatron committed May 10, 2017
commit 59047bc64464ae4565c2712ae9d0c03ec580722c
@@ -295,11 +295,11 @@ private double score(SingularityOfferHolder offerHolder, SingularitySchedulerSta
double longRunningCpusUsedScore = longRunningTasksUsage.get(ResourceUsageType.CPU_USED).doubleValue() / slaveUsage.getCpuTotal().get();
double longRunningMemUsedScore = ((double) longRunningTasksUsage.get(ResourceUsageType.MEMORY_BYTES_USED).longValue() / slaveUsage.getMemoryBytesTotal().get());
double cpusTotalScore = (MesosUtils.getNumCpus(offer) / slaveUsage.getCpuTotal().get());
double memTotalScore = (MesosUtils.getMemory(offer) / slaveUsage.getMemoryMbTotal().get());
double cpusFreeScore = 1 - (slaveUsage.getCpusReserved() / slaveUsage.getCpuTotal().get());
double memFreeScore = 1 - ((double) slaveUsage.getMemoryMbReserved() / slaveUsage.getMemoryMbTotal().get());
return isLongRunning(taskRequest) ? scoreLongRunningTask(longRunningMemUsedScore, memTotalScore, longRunningCpusUsedScore, cpusTotalScore)
: scoreNonLongRunningTask(taskRequest, longRunningMemUsedScore, memTotalScore, longRunningCpusUsedScore, cpusTotalScore);
return isLongRunning(taskRequest) ? scoreLongRunningTask(longRunningMemUsedScore, memFreeScore, longRunningCpusUsedScore, cpusFreeScore)
: scoreNonLongRunningTask(taskRequest, longRunningMemUsedScore, memFreeScore, longRunningCpusUsedScore, cpusFreeScore);
}
private boolean isMissingUsageData(Optional<SingularitySlaveUsageWithId> maybeSlaveUsage) {
@@ -314,12 +314,12 @@ private boolean isLongRunning(SingularityTaskRequest taskRequest) {
return taskRequest.getRequest().getRequestType().isLongRunning();
}
private double scoreLongRunningTask(double longRunningMemUsedScore, double memTotalScore, double longRunningCpusUsedScore, double cpusTotalScore) {
private double scoreLongRunningTask(double longRunningMemUsedScore, double memFreeScore, double longRunningCpusUsedScore, double cpusFreeScore) {
// usage improves score
return calculateScore(1 - longRunningMemUsedScore, memTotalScore, 1 - longRunningCpusUsedScore, cpusTotalScore, 0.50, 0.50);
return calculateScore(1 - longRunningMemUsedScore, memFreeScore, 1 - longRunningCpusUsedScore, cpusFreeScore, 0.50, 0.50);
}
private double scoreNonLongRunningTask(SingularityTaskRequest taskRequest, double longRunningMemUsedScore, double memTotalScore, double longRunningCpusUsedScore, double cpusTotalScore) {
private double scoreNonLongRunningTask(SingularityTaskRequest taskRequest, double longRunningMemUsedScore, double memFreeScore, double longRunningCpusUsedScore, double cpusFreeScore) {
Optional<SingularityDeployStatistics> statistics = deployManager.getDeployStatistics(taskRequest.getRequest().getId(), taskRequest.getDeploy().getId());
final double epsilon = 0.0001;
@@ -331,23 +331,23 @@ private double scoreNonLongRunningTask(SingularityTaskRequest taskRequest, doubl
usedResourceWeight = Math.min((double) TimeUnit.MILLISECONDS.toSeconds(statistics.get().getAverageRuntimeMillis().get()) / configuration.getConsiderNonLongRunningTaskLongRunningAfterRunningForSeconds(), 1) * maxNonLongRunningUsedResourceWeight;
if (Math.abs(usedResourceWeight - maxNonLongRunningUsedResourceWeight) < epsilon) {
return scoreLongRunningTask(longRunningMemUsedScore, memTotalScore, longRunningCpusUsedScore, cpusTotalScore);
return scoreLongRunningTask(longRunningMemUsedScore, memFreeScore, longRunningCpusUsedScore, cpusFreeScore);
}
freeResourceWeight = 1 - usedResourceWeight;
}
// usage reduces score
return calculateScore(longRunningMemUsedScore, memTotalScore, longRunningCpusUsedScore, cpusTotalScore, freeResourceWeight, usedResourceWeight * -1);
return calculateScore(longRunningMemUsedScore, memFreeScore, longRunningCpusUsedScore, cpusFreeScore, freeResourceWeight, usedResourceWeight * -1);
}

This comment has been minimized.

@darcatron

darcatron Apr 27, 2017

Contributor

These changes will be easiest to discuss in person.

Essentially, long running tasks consider an offer 50:50 for usage and free space. non long running offers vary depending on how long they've been running with a default at the middle (25:75). non long running offers favor free space and will score lower if they run for a large amount of time and there are long running tasks on the offered machine

@darcatron

darcatron Apr 27, 2017

Contributor

These changes will be easiest to discuss in person.

Essentially, long running tasks consider an offer 50:50 for usage and free space. non long running offers vary depending on how long they've been running with a default at the middle (25:75). non long running offers favor free space and will score lower if they run for a large amount of time and there are long running tasks on the offered machine

private double calculateScore(double longRunningMemUsedScore, double memTotalScore, double longRunningCpusUsedScore, double cpusTotalScore, double freeResourceWeight, double usedResourceWeight) {
private double calculateScore(double longRunningMemUsedScore, double memFreeScore, double longRunningCpusUsedScore, double cpusFreeScore, double freeResourceWeight, double usedResourceWeight) {
double score = 0;
score += (configuration.getLongRunningUsedCpuWeightForOffer() * usedResourceWeight) * longRunningCpusUsedScore;
score += (configuration.getLongRunningUsedMemWeightForOffer() * usedResourceWeight) * longRunningMemUsedScore;
score += (configuration.getFreeCpuWeightForOffer() * freeResourceWeight) * cpusTotalScore;
score += (configuration.getFreeMemWeightForOffer() * freeResourceWeight) * memTotalScore;
score += (configuration.getFreeCpuWeightForOffer() * freeResourceWeight) * cpusFreeScore;
score += (configuration.getFreeMemWeightForOffer() * freeResourceWeight) * memFreeScore;
return score;
}
ProTip! Use n and p to navigate between commits in a pull request.