Skip to content

Commit

Permalink
add time window and task limit for craned when scheduling.
Browse files Browse the repository at this point in the history
  • Loading branch information
NamelessOIer committed Nov 28, 2024
1 parent b4bde90 commit 6de6b95
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/CraneCtld/TaskScheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2007,6 +2007,15 @@ bool MinLoadFirst::CalculateRunningNodesAndStartTime_(
}
auto& time_avail_res_map =
node_selection_info.node_time_avail_res_map.at(craned_index);
// Number of tasks is not less than map size.
// When condition is true, the craned has too many tasks.
if (time_avail_res_map.size() >= kAlgoMaxTaskNumPerNode) {
if constexpr (kAlgoTraceOutput) {
CRANE_TRACE("Craned {} has too many tasks. Skipping this craned.",
craned_index);
}
continue;
}
auto craned_meta = craned_meta_map.at(craned_index).GetExclusivePtr();

// If any of the follow `if` is true, skip this node.
Expand Down Expand Up @@ -2084,6 +2093,9 @@ bool MinLoadFirst::CalculateRunningNodesAndStartTime_(
absl::Time last_time = absl::InfinitePast();
while (!pq.empty()) {
absl::Time time = pq.top()->it->first;
if (time - now > kAlgoMaxTimeWindow) {
return false;
}
while (!pq.empty() && pq.top()->it->first == time) {
auto tmp = pq.top();
pq.pop();
Expand Down
4 changes: 4 additions & 0 deletions src/CraneCtld/TaskScheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

#pragma once

#include <absl/time/time.h>

#include "CtldPublicDefs.h"
// Precompiled header comes first!

Expand Down Expand Up @@ -144,6 +146,8 @@ class MinLoadFirst : public INodeSelectionAlgo {
private:
static constexpr bool kAlgoTraceOutput = false;
static constexpr bool kAlgoRedundantNode = true;
static constexpr uint32_t kAlgoMaxTaskNumPerNode = 1000;
static constexpr absl::Duration kAlgoMaxTimeWindow = absl::Hours(24 * 7);

/**
* This map stores how much resource is available
Expand Down

0 comments on commit 6de6b95

Please sign in to comment.