Skip to content

Commit

Permalink
batch-scheduler: fix the number of cross-vm links computation (#367)
Browse files Browse the repository at this point in the history
* batch-scheduler: fix the number of cross-vm links computation

* chore: bump patch code version
  • Loading branch information
csegarragonz authored Jan 25, 2024
1 parent d7d8e97 commit 62c022d
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 12 deletions.
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

0 comments on commit 62c022d

Please sign in to comment.