Skip to content

Commit

Permalink
Enable/disable scheduling topology hints through an env. variable (#188)
Browse files Browse the repository at this point in the history
* allow setting the scheduling policy from an environment variable

* set to on by default

* changing env var name and adding a test for the actual scheduling decision
  • Loading branch information
csegarragonz committed Dec 2, 2021
1 parent 0af426c commit 6ff81aa
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/faabric/util/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class SystemConfig
// Scheduling
int noScheduler;
int overrideCpuCount;
std::string noTopologyHints;

// Worker-related timeouts
int globalMessageTimeout;
Expand Down
8 changes: 8 additions & 0 deletions src/scheduler/Scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,14 @@ 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.noTopologyHints == "on" &&
topologyHint != faabric::util::SchedulingTopologyHint::NORMAL) {
SPDLOG_WARN("Ignoring topology hint passed to scheduler as hints are "
"disabled in the config");
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");
noTopologyHints = getEnvVar("NO_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("NO_TOPOLOGY_HINTS {}", noTopologyHints);

SPDLOG_INFO("--- Timeouts ---");
SPDLOG_INFO("GLOBAL_MESSAGE_TIMEOUT {}", globalMessageTimeout);
Expand Down
31 changes: 31 additions & 0 deletions tests/test/scheduler/test_scheduling_decisions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,37 @@ TEST_CASE_METHOD(SchedulingDecisionTestFixture,
testActualSchedulingDecision(req, config);
}

TEST_CASE_METHOD(SchedulingDecisionTestFixture,
"Test scheduling hints can be disabled through the config",
"[scheduler]")
{
SchedulingConfig config = {
.hosts = { masterHost, "hostA" },
.slots = { 1, 1 },
.numReqs = 2,
.topologyHint = faabric::util::SchedulingTopologyHint::FORCE_LOCAL,
.expectedHosts = { masterHost, "hostA" },
};

auto req = faabric::util::batchExecFactory("foo", "bar", config.numReqs);
auto& faabricConf = faabric::util::getSystemConfig();

SECTION("Config. variable set")
{
faabricConf.noTopologyHints = "on";
config.expectedHosts = { masterHost, "hostA" };
}

SECTION("Config. variable not set")
{
config.expectedHosts = { masterHost, masterHost };
}

testActualSchedulingDecision(req, config);

faabricConf.reset();
}

TEST_CASE_METHOD(SchedulingDecisionTestFixture,
"Test master running out of resources",
"[scheduler]")
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.noTopologyHints == "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 noTopologyHints = setEnvVar("NO_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.noTopologyHints == "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", noTopologyHints);

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

0 comments on commit 6ff81aa

Please sign in to comment.