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

batch-scheduler: fix the number of cross-vm links computation #367

Merged
merged 2 commits into from
Jan 25, 2024
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
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FAABRIC_VERSION=0.13.0
FAABRIC_CLI_IMAGE=faasm.azurecr.io/faabric:0.13.0
FAABRIC_VERSION=0.13.1
FAABRIC_CLI_IMAGE=faasm.azurecr.io/faabric:0.13.1
COMPOSE_PROJECT_NAME=faabric-dev
CONAN_CACHE_MOUNT_SOURCE=./conan-cache/
12 changes: 6 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
container:
image: faasm.azurecr.io/faabric:0.13.0
image: faasm.azurecr.io/faabric:0.13.1
credentials:
username: ${{ secrets.ACR_SERVICE_PRINCIPAL_ID }}
password: ${{ secrets.ACR_SERVICE_PRINCIPAL_PASSWORD }}
Expand All @@ -33,7 +33,7 @@ jobs:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
container:
image: faasm.azurecr.io/faabric:0.13.0
image: faasm.azurecr.io/faabric:0.13.1
credentials:
username: ${{ secrets.ACR_SERVICE_PRINCIPAL_ID }}
password: ${{ secrets.ACR_SERVICE_PRINCIPAL_PASSWORD }}
Expand All @@ -47,7 +47,7 @@ jobs:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
container:
image: faasm.azurecr.io/faabric:0.13.0
image: faasm.azurecr.io/faabric:0.13.1
credentials:
username: ${{ secrets.ACR_SERVICE_PRINCIPAL_ID }}
password: ${{ secrets.ACR_SERVICE_PRINCIPAL_PASSWORD }}
Expand All @@ -70,7 +70,7 @@ jobs:
REDIS_QUEUE_HOST: redis
REDIS_STATE_HOST: redis
container:
image: faasm.azurecr.io/faabric:0.13.0
image: faasm.azurecr.io/faabric:0.13.1
credentials:
username: ${{ secrets.ACR_SERVICE_PRINCIPAL_ID }}
password: ${{ secrets.ACR_SERVICE_PRINCIPAL_PASSWORD }}
Expand Down Expand Up @@ -110,7 +110,7 @@ jobs:
REDIS_QUEUE_HOST: redis
REDIS_STATE_HOST: redis
container:
image: faasm.azurecr.io/faabric:0.13.0
image: faasm.azurecr.io/faabric:0.13.1
credentials:
username: ${{ secrets.ACR_SERVICE_PRINCIPAL_ID }}
password: ${{ secrets.ACR_SERVICE_PRINCIPAL_PASSWORD }}
Expand Down Expand Up @@ -164,7 +164,7 @@ jobs:
REDIS_QUEUE_HOST: redis
REDIS_STATE_HOST: redis
container:
image: faasm.azurecr.io/faabric:0.13.0
image: faasm.azurecr.io/faabric:0.13.1
credentials:
username: ${{ secrets.ACR_SERVICE_PRINCIPAL_ID }}
password: ${{ secrets.ACR_SERVICE_PRINCIPAL_PASSWORD }}
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.13.0
0.13.1
21 changes: 18 additions & 3 deletions src/batch-scheduler/BinPackScheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ bool BinPackScheduler::isFirstDecisionBetter(
std::shared_ptr<SchedulingDecision> decisionA,
std::shared_ptr<SchedulingDecision> decisionB)
{
// The locality score is currently the number of cross-VM links. You may
// calculate this number as follows:
// - If the decision is single host, the number of cross-VM links is zero
// - Otherwise, in a fully-connected graph, the number of cross-VM links
// is the sum of edges that cross a VM boundary
auto getLocalityScore =
[](std::shared_ptr<SchedulingDecision> decision) -> std::pair<int, int> {
// First, calculate the host-message histogram (or frequency count)
Expand All @@ -115,12 +120,22 @@ bool BinPackScheduler::isFirstDecisionBetter(
return std::make_pair(1, 0);
}

// Else, do the product of all entries
int score = 1;
// Else, sum all the egressing edges for each element and divide by two
int score = 0;
for (auto [host, freq] : hostFreqCount) {
score = score * freq;

int thisHostScore = 0;
for (auto [innerHost, innerFreq] : hostFreqCount) {
if (innerHost != host) {
thisHostScore += innerFreq;
}
}

score += thisHostScore * freq;
}

score = int(score / 2);

return std::make_pair(hostFreqCount.size(), score);
};

Expand Down
20 changes: 20 additions & 0 deletions tests/test/batch-scheduler/test_binpack_scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,26 @@ TEST_CASE_METHOD(BinPackSchedulerTestFixture,
ber, { "foo", "foo", "foo", "bar", "bar", "foo" });
}

// Check we correctly minimise cross-VM links in >2 VM scenarios
SECTION("It also minimises cross-VM links with more than 2 VMs")
{
config.hostMap = buildHostMap(
{
"foo",
"bar",
"baz",
"bat",
},
{ 2, 2, 1, 1 },
{ 1, 1, 1, 1 });
ber = faabric::util::batchExecFactory("bat", "man", 4);
ber->set_type(BatchExecuteRequest_BatchExecuteType_MIGRATION);
config.inFlightReqs =
buildInFlightReqs(ber, 4, { "foo", "bar", "baz", "bat" });
config.expectedDecision =
buildExpectedDecision(ber, { "foo", "bar", "bar", "foo" });
}

SECTION("BinPack will minimise the number of messages to migrate")
{
config.hostMap =
Expand Down
Loading