Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable/disable scheduling topology hints through an env. variable #188

Merged
merged 3 commits into from
Dec 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would change this to check if they're requesting anything other than NORMAL, then print a warning if so. We don't want to have this on accidentally.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Now we:

  1. Check if env var set
  2. If set and hint different than NORMAL, print a warning and unset.


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 = {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I add the new test

.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]")

csegarragonz marked this conversation as resolved.
Show resolved Hide resolved
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