Skip to content
Snippets Groups Projects
Commit 1bc3fed5 authored by jgatt's avatar jgatt
Browse files

optimization of scheduler we sort only if the queue had more than 10 jobs added

parent e3e2e7f5
Branches
Tags
1 merge request!16Merge request multibehavior
......@@ -227,6 +227,17 @@ void Queue::insert_job(const Job *job)
_jobs.push_back(sjob);
}
void Queue::insert_sorted_job(const Job * job, const SortableJobOrder::UpdateInformation *update_info , const SortableJobOrder::CompareInformation * compare_info){
SortableJob * sjob = new SortableJob;
sjob->job = job;
sjob->release_date = update_info->current_date;
auto start = _jobs.begin();
auto end = _jobs.end();
while(start!=end && _order->compare((*start), sjob, compare_info)) {
++start;
}
_jobs.insert(start,sjob);
}
std::list<SortableJob *>::iterator Queue::remove_job(const Job *job)
{
auto it = std::find_if(_jobs.begin(), _jobs.end(),
......
......@@ -106,7 +106,9 @@ public:
/* Insert the job at the beginning of the queue, setting its release_date
* to the job's submission date. */
void insert_job(const Job * job);
void insert_sorted_job(const Job * job,const SortableJobOrder::UpdateInformation * update_info ,
const SortableJobOrder::CompareInformation * compare_info);
std::list<SortableJob *>::iterator remove_job(const Job * job);
std::list<SortableJob *>::iterator remove_job(std::list<SortableJob *>::iterator job_it);
void sort_queue(SortableJobOrder::UpdateInformation * update_info, SortableJobOrder::CompareInformation * compare_info = nullptr);
......
......@@ -237,7 +237,7 @@ void BinPackingEnergy::make_decisions(double date,
* Handle recently released jobs from worklaod: put them in the
* queue
**********************************************************************/
bool modified_queue = false;
bool sort_queue = _jobs_released_recently.size() >=10;
for (const std::string &new_job_id : _jobs_released_recently)
{
const Job *new_job = (*_workload)[new_job_id];
......@@ -251,8 +251,14 @@ void BinPackingEnergy::make_decisions(double date,
else
{
_queue->append_job(new_job, update_info);
modified_queue = true;
if(sort_queue)
{
_queue->append_job(new_job, update_info);
}
else
{
_queue->insert_sorted_job(new_job,update_info,nullptr);
}
}
}
/**********************************************************************
......@@ -262,12 +268,14 @@ void BinPackingEnergy::make_decisions(double date,
* available core)
**********************************************************************/
if (modified_queue)
if (sort_queue)
{
_queue->sort_queue(update_info, compare_info);
}
listofHosts.sort(HostComparator());
if (_queue->nb_jobs()>0)
{
listofHosts.sort(HostComparator());
}
/* Go through the job queue and try to schedule the jobs */
LOG_F(1, "makedecisions, queue of job has size %d", _queue->nb_jobs());
for (auto job_it = _queue->begin(); job_it != _queue->end();)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment