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 @@ ...@@ -3,7 +3,6 @@
//#include <loguru.hpp> //#include <loguru.hpp>
#include "../pempek_assert.hpp" #include "../pempek_assert.hpp"
#include <cstddef>
EasyBackfillingFast::EasyBackfillingFast(Workload *workload, EasyBackfillingFast::EasyBackfillingFast(Workload *workload,
SchedulingDecision *decision, Queue *queue, ResourceSelector *selector, SchedulingDecision *decision, Queue *queue, ResourceSelector *selector,
...@@ -50,9 +49,6 @@ void EasyBackfillingFast::make_decisions(double date, ...@@ -50,9 +49,6 @@ void EasyBackfillingFast::make_decisions(double date,
// - only handles one priority job (the first of the queue) // - only handles one priority job (the first of the queue)
// - only handles time as floating-point (-> precision errors). // - 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; bool job_ended = false;
// Handle newly finished jobs // Handle newly finished jobs
...@@ -122,7 +118,7 @@ void EasyBackfillingFast::make_decisions(double date, ...@@ -122,7 +118,7 @@ void EasyBackfillingFast::make_decisions(double date,
{ {
// The job becomes priority! // The job becomes priority!
_priority_job = pending_job; _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); _pending_jobs.erase(job_it);
// Stop first queue traversal. // Stop first queue traversal.
...@@ -137,7 +133,7 @@ void EasyBackfillingFast::make_decisions(double date, ...@@ -137,7 +133,7 @@ void EasyBackfillingFast::make_decisions(double date,
// Update priority job expected starting time (might have changed if a recently ended job // Update priority job expected starting time (might have changed if a recently ended job
// completed before its walltime) // completed before its walltime)
if (_priority_job != nullptr) 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(); for (auto job_it = _pending_jobs.begin();
job_it != _pending_jobs.end(); ) job_it != _pending_jobs.end(); )
...@@ -145,7 +141,7 @@ void EasyBackfillingFast::make_decisions(double date, ...@@ -145,7 +141,7 @@ void EasyBackfillingFast::make_decisions(double date,
const Job * pending_job = *job_it; const Job * pending_job = *job_it;
// Can the job be executed now ? // Can the job be executed now ?
if (pending_job->nb_requested_resources <= _nb_available_machines && 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! // Yes, it can be backfilled!
alloc.machines = _available_machines.left( alloc.machines = _available_machines.left(
...@@ -198,7 +194,7 @@ void EasyBackfillingFast::make_decisions(double date, ...@@ -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()); //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?) // Can it be executed now (without hindering priority job?)
if (_priority_job == nullptr || 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()); //LOG_F(INFO, "Job %s can be started right away!", new_job->id.c_str());
// Yes, the job can be executed right away! // Yes, the job can be executed right away!
...@@ -222,7 +218,7 @@ void EasyBackfillingFast::make_decisions(double date, ...@@ -222,7 +218,7 @@ void EasyBackfillingFast::make_decisions(double date,
{ {
// No, the job cannot be executed (hinders priority job.) // 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)", /*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); _pending_jobs.push_back(new_job);
} }
} }
...@@ -234,7 +230,7 @@ void EasyBackfillingFast::make_decisions(double date, ...@@ -234,7 +230,7 @@ void EasyBackfillingFast::make_decisions(double date,
{ {
// The job becomes priority. // The job becomes priority.
_priority_job = new_job; _priority_job = new_job;
_priority_job->completion_time = compute_priority_job_expected_earliest_starting_time(); update_priority_job_expected_earliest_start_time();
} }
else else
{ {
...@@ -245,7 +241,7 @@ void EasyBackfillingFast::make_decisions(double date, ...@@ -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 nb_available = _nb_available_machines;
int required = _priority_job->nb_requested_resources; int required = _priority_job->nb_requested_resources;
...@@ -256,12 +252,14 @@ double EasyBackfillingFast::compute_priority_job_expected_earliest_starting_time ...@@ -256,12 +252,14 @@ double EasyBackfillingFast::compute_priority_job_expected_earliest_starting_time
if (nb_available >= required) 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."); 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) std::list<EasyBackfillingFast::FinishedHorizonPoint>::iterator EasyBackfillingFast::insert_horizon_point(const EasyBackfillingFast::FinishedHorizonPoint &point)
......
...@@ -39,7 +39,7 @@ private: ...@@ -39,7 +39,7 @@ private:
}; };
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); std::list<FinishedHorizonPoint>::iterator insert_horizon_point(const FinishedHorizonPoint & point);
private: private:
...@@ -59,4 +59,6 @@ private: ...@@ -59,4 +59,6 @@ private:
// At any time, null if there is no priority job (no waiting job) // At any time, null if there is no priority job (no waiting job)
Job * _priority_job = nullptr; 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