Skip to content

Commit

Permalink
allow setting the scheduling policy from an environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
csegarragonz committed Nov 30, 2021
1 parent 27ffd58 commit 4db2985
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/scheduler/Scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,11 @@ faabric::util::SchedulingDecision Scheduler::makeSchedulingDecision(
faabric::Message& firstMsg = req->mutable_messages()->at(0);
std::string funcStr = faabric::util::funcToString(firstMsg, false);

// If topology hints are disabled, unset the provided topology hint
if (conf.useTopologyHints == "off") {
topologyHint = faabric::util::SchedulingTopologyHint::NORMAL;
}

std::vector<std::string> hosts;
if (topologyHint == faabric::util::SchedulingTopologyHint::FORCE_LOCAL) {
// We're forced to execute locally here so we do all the messages
Expand Down
2 changes: 2 additions & 0 deletions src/util/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ void SystemConfig::initialise()
// Scheduling
noScheduler = this->getSystemConfIntParam("NO_SCHEDULER", "0");
overrideCpuCount = this->getSystemConfIntParam("OVERRIDE_CPU_COUNT", "0");
useTopologyHints = getEnvVar("USE_TOPOLOGY_HINTS", "off");

// Worker-related timeouts (all in seconds)
globalMessageTimeout =
Expand Down Expand Up @@ -100,6 +101,7 @@ void SystemConfig::print()
SPDLOG_INFO("--- Scheduling ---");
SPDLOG_INFO("NO_SCHEDULER {}", noScheduler);
SPDLOG_INFO("OVERRIDE_CPU_COUNT {}", overrideCpuCount);
SPDLOG_INFO("USE_TOPOLOGY_HINTS {}", useTopologyHints);

SPDLOG_INFO("--- Timeouts ---");
SPDLOG_INFO("GLOBAL_MESSAGE_TIMEOUT {}", globalMessageTimeout);
Expand Down
4 changes: 4 additions & 0 deletions tests/test/util/test_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ TEST_CASE("Test default system config initialisation", "[util]")

REQUIRE(conf.noScheduler == 0);
REQUIRE(conf.overrideCpuCount == 0);
REQUIRE(conf.useTopologyHints == "off");

REQUIRE(conf.globalMessageTimeout == 60000);
REQUIRE(conf.boundTimeout == 30000);
Expand All @@ -44,6 +45,7 @@ TEST_CASE("Test overriding system config initialisation", "[util]")

std::string noScheduler = setEnvVar("NO_SCHEDULER", "1");
std::string overrideCpuCount = setEnvVar("OVERRIDE_CPU_COUNT", "4");
std::string useTopologyHints = setEnvVar("USE_TOPOLOGY_HINTS", "on");

std::string globalTimeout = setEnvVar("GLOBAL_MESSAGE_TIMEOUT", "9876");
std::string boundTimeout = setEnvVar("BOUND_TIMEOUT", "6666");
Expand All @@ -70,6 +72,7 @@ TEST_CASE("Test overriding system config initialisation", "[util]")

REQUIRE(conf.noScheduler == 1);
REQUIRE(conf.overrideCpuCount == 4);
REQUIRE(conf.useTopologyHints == "on");

REQUIRE(conf.globalMessageTimeout == 9876);
REQUIRE(conf.boundTimeout == 6666);
Expand All @@ -95,6 +98,7 @@ TEST_CASE("Test overriding system config initialisation", "[util]")

setEnvVar("NO_SCHEDULER", noScheduler);
setEnvVar("OVERRIDE_CPU_COUNT", overrideCpuCount);
setEnvVar("USE_TOPOLOGY_HINTS", useTopologyHints);

setEnvVar("GLOBAL_MESSAGE_TIMEOUT", globalTimeout);
setEnvVar("BOUND_TIMEOUT", boundTimeout);
Expand Down

0 comments on commit 4db2985

Please sign in to comment.