diff --git a/src/algo/easy_bf_fast.cpp b/src/algo/easy_bf_fast.cpp index e0cf86265a08803036f3a5f132267f445aec16ee..f27af5c4c689bcc49101c79e0c2111ac33d43c1a 100644 --- a/src/algo/easy_bf_fast.cpp +++ b/src/algo/easy_bf_fast.cpp @@ -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) diff --git a/src/algo/easy_bf_fast.hpp b/src/algo/easy_bf_fast.hpp index c1013520708c5a874d37e432ea64d4c5d18001ce..5a449bce0fa3499005309d8d9dc5b90600aa198a 100644 --- a/src/algo/easy_bf_fast.hpp +++ b/src/algo/easy_bf_fast.hpp @@ -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; };