Added lookahead scheduler.

Most scheduler now use estimated finish time instead of predicted execution time.
This commit is contained in:
Matthias
2017-07-26 18:56:44 +02:00
parent b93d8565a0
commit 19d695d4d8
13 changed files with 468 additions and 110 deletions
+38
View File
@@ -67,6 +67,7 @@ void SchedulerBase::notifyWEPUpdate(wep::WorkflowExecutionPlan& wep, std::set<we
bool SchedulerBase::executeSchedulingDecision(WepMapEntry& wepe, std::shared_ptr<SchedulingDecision> sd, std::unique_lock<std::mutex>& schedulerLock) noexcept {
wepe.decisions.insert(sd);
scheduledTasks[sd->resource].push_back(sd);
schedulerLock.unlock();
sd->activityInstance->setSchedulingDecision(sd);
if (sd->activityInstance->activityType() == wfs::ActivityType::Atomic) {
@@ -92,6 +93,13 @@ void SchedulerBase::notifySchedulingDecisionStatusUpdate(std::shared_ptr<Schedul
std::unique_lock<std::mutex> objLock(schedulerMutex);
auto wepe = wepMap.find(sd->wep);
if (wepe != wepMap.end()) {
auto& innerMap = scheduledTasks[sd->resource];
for (auto i = innerMap.begin(); i != innerMap.end(); i++) {
if (*i == sd) {
innerMap.erase(i);
break;
}
}
_notifySchedulingDecisionStatusUpdate(wepe->second, sd, objLock);
// Notify enactment engine
auto ee = wepe->second.engine;
@@ -102,6 +110,36 @@ void SchedulerBase::notifySchedulingDecisionStatusUpdate(std::shared_ptr<Schedul
}
}
double SchedulerBase::_getResourceEstimatedAvailableTime(resource::ComputingResource* resource) {
if (resource->getFreeSlotCount() > 0) {
return 0.0;
} else {
// Calculating the estimated available time for resources with more than 1 slot is not trivial
// Here we are employing a heuristic that partitions the scheduled tasks into chunks the size of the maximal slot count,
// takes the minimum time of each chunk and adds them together.
unsigned i = 0;
double eat = 0;
double minTime = -1;
auto& tasks = scheduledTasks[resource];
for (auto t : tasks) {
i++;
if (minTime < 0) {
minTime = t->getPrediction().getExecutionTime().getValue();
} else {
if (i > resource->getMaxSlotCount()) {
eat += minTime;
i = 0;
minTime = t->getPrediction().getExecutionTime().getValue();
} else {
if (t->getPrediction().getExecutionTime().getValue() < minTime) {
minTime = t->getPrediction().getExecutionTime().getValue();
}
}
}
}
return eat;
}
}
} /* namespace scheduling */
} /* namespace wfr */