Skip to content

Commit

Permalink
optimize efficiency
Browse files Browse the repository at this point in the history
  • Loading branch information
NamelessOIer committed Dec 5, 2024
1 parent 1d44760 commit 007c978
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/CraneCtld/TaskScheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2110,11 +2110,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 <=
Expand Down
12 changes: 10 additions & 2 deletions src/CraneCtld/TaskScheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 007c978

Please sign in to comment.