diff --git a/src/CraneCtld/TaskScheduler.cpp b/src/CraneCtld/TaskScheduler.cpp index 0047d0464..6ee30e379 100644 --- a/src/CraneCtld/TaskScheduler.cpp +++ b/src/CraneCtld/TaskScheduler.cpp @@ -2130,11 +2130,10 @@ bool MinLoadFirst::CalculateRunningNodesAndStartTime_( pq.pop(); if (tracker->satisfied()) { satisfied_trackers.try_push_back(tracker, time); + if (tracker->genNextUnsatisfied()) pq.emplace(tracker); } else { satisfied_trackers.try_erase(tracker); - } - if (tracker->genNext()) { - pq.emplace(tracker); + if (tracker->genNextSatisfied()) pq.emplace(tracker); } } if (pq.empty() || satisfied_trackers.kth_time() + task->time_limit <= diff --git a/src/CraneCtld/TaskScheduler.h b/src/CraneCtld/TaskScheduler.h index 1212d5265..305c6cbdb 100644 --- a/src/CraneCtld/TaskScheduler.h +++ b/src/CraneCtld/TaskScheduler.h @@ -141,7 +141,7 @@ class MinLoadFirst : public INodeSelectionAlgo { private: static constexpr bool kAlgoTraceOutput = false; - static constexpr bool kAlgoRedundantNode = true; + static constexpr bool kAlgoRedundantNode = false; static constexpr uint32_t kAlgoMaxTaskNumPerNode = 1000; static constexpr absl::Duration kAlgoMaxTimeWindow = absl::Hours(24 * 7); @@ -175,7 +175,15 @@ class MinLoadFirst : public INodeSelectionAlgo { bool satisfied() const { return *task_res <= it->second; } - bool genNext() { return ++it != end; } + bool genNextUnsatisfied() { + while (++it != end && satisfied()); + return it != end; + } + + bool genNextSatisfied() { + while (++it != end && !satisfied()); + return it != end; + } }; struct TrackerList {