Skip to content
Snippets Groups Projects
Commit 7d465ab0 authored by Maël Madon's avatar Maël Madon
Browse files

refac: add a specific variable _priority_job_expected_start_time to stop...

refac: add a specific variable _priority_job_expected_start_time to stop storing that info in _priority_job->completion_time
parent 538a50b2
No related branches found
No related tags found
No related merge requests found
......@@ -3,7 +3,6 @@
//#include <loguru.hpp>
#include "../pempek_assert.hpp"
#include <cstddef>
EasyBackfillingFast::EasyBackfillingFast(Workload *workload,
SchedulingDecision *decision, Queue *queue, ResourceSelector *selector,
......@@ -50,9 +49,6 @@ void EasyBackfillingFast::make_decisions(double date,
// - only handles one priority job (the first of the queue)
// - only handles time as floating-point (-> precision errors).
// Hacks:
// - uses priority job's completion time to store its expected starting time
bool job_ended = false;
// Handle newly finished jobs
......@@ -122,7 +118,7 @@ void EasyBackfillingFast::make_decisions(double date,
{
// The job becomes priority!
_priority_job = pending_job;
_priority_job->completion_time = compute_priority_job_expected_earliest_starting_time();
update_priority_job_expected_earliest_start_time();
_pending_jobs.erase(job_it);
// Stop first queue traversal.
......@@ -137,7 +133,7 @@ void EasyBackfillingFast::make_decisions(double date,
// Update priority job expected starting time (might have changed if a recently ended job
// completed before its walltime)
if (_priority_job != nullptr)
_priority_job->completion_time = compute_priority_job_expected_earliest_starting_time();
update_priority_job_expected_earliest_start_time();
for (auto job_it = _pending_jobs.begin();
job_it != _pending_jobs.end(); )
......@@ -145,7 +141,7 @@ void EasyBackfillingFast::make_decisions(double date,
const Job * pending_job = *job_it;
// Can the job be executed now ?
if (pending_job->nb_requested_resources <= _nb_available_machines &&
date + pending_job->walltime <= _priority_job->completion_time)
date + pending_job->walltime <= _priority_job_expected_start_time)
{
// Yes, it can be backfilled!
alloc.machines = _available_machines.left(
......@@ -198,7 +194,7 @@ void EasyBackfillingFast::make_decisions(double date,
//LOG_F(INFO, "There are enough available resources (%d) to execute job %s", _nb_available_machines, new_job->id.c_str());
// Can it be executed now (without hindering priority job?)
if (_priority_job == nullptr ||
date + new_job->walltime <= _priority_job->completion_time)
date + new_job->walltime <= _priority_job_expected_start_time)
{
//LOG_F(INFO, "Job %s can be started right away!", new_job->id.c_str());
// Yes, the job can be executed right away!
......@@ -222,7 +218,7 @@ void EasyBackfillingFast::make_decisions(double date,
{
// No, the job cannot be executed (hinders priority job.)
/*LOG_F(INFO, "Not enough time to execute job %s (walltime=%g, priority job expected starting time=%g)",
new_job->id.c_str(), (double)new_job->walltime, _priority_job->completion_time);*/
new_job->id.c_str(), (double)new_job->walltime, _priority_job_expected_start_time);*/
_pending_jobs.push_back(new_job);
}
}
......@@ -234,7 +230,7 @@ void EasyBackfillingFast::make_decisions(double date,
{
// The job becomes priority.
_priority_job = new_job;
_priority_job->completion_time = compute_priority_job_expected_earliest_starting_time();
update_priority_job_expected_earliest_start_time();
}
else
{
......@@ -245,7 +241,7 @@ void EasyBackfillingFast::make_decisions(double date,
}
}
double EasyBackfillingFast::compute_priority_job_expected_earliest_starting_time()
void EasyBackfillingFast::update_priority_job_expected_earliest_start_time()
{
int nb_available = _nb_available_machines;
int required = _priority_job->nb_requested_resources;
......@@ -256,12 +252,14 @@ double EasyBackfillingFast::compute_priority_job_expected_earliest_starting_time
if (nb_available >= required)
{
return it->date;
_priority_job_expected_start_time = it->date;
_remaining_resources_at_priority_job_start = nb_available - required;
return;
}
}
PPK_ASSERT_ERROR(false, "The job will never be executable.");
return 0;
return;
}
std::list<EasyBackfillingFast::FinishedHorizonPoint>::iterator EasyBackfillingFast::insert_horizon_point(const EasyBackfillingFast::FinishedHorizonPoint &point)
......
......@@ -39,7 +39,7 @@ private:
};
private:
double compute_priority_job_expected_earliest_starting_time();
void update_priority_job_expected_earliest_start_time();
std::list<FinishedHorizonPoint>::iterator insert_horizon_point(const FinishedHorizonPoint & point);
private:
......@@ -59,4 +59,6 @@ private:
// At any time, null if there is no priority job (no waiting job)
Job * _priority_job = nullptr;
double _priority_job_expected_start_time = -1;
int _remaining_resources_at_priority_job_start = -1;
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment