Skip to content

Commit

Permalink
Add method to log scheduling decision (#348)
Browse files Browse the repository at this point in the history
* decisions: add method to debug print a decision

* tests: test print function in tests
  • Loading branch information
csegarragonz authored Aug 7, 2023
1 parent 957ae10 commit c725c04
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/faabric/batch-scheduler/SchedulingDecision.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ class SchedulingDecision
int32_t groupIdx);

std::set<std::string> uniqueHosts();

void print();
};

}
19 changes: 19 additions & 0 deletions src/batch-scheduler/SchedulingDecision.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <faabric/batch-scheduler/SchedulingDecision.h>
#include <faabric/util/config.h>
#include <faabric/util/logging.h>

namespace faabric::batch_scheduler {

Expand Down Expand Up @@ -57,4 +58,22 @@ std::set<std::string> SchedulingDecision::uniqueHosts()
{
return std::set<std::string>(hosts.begin(), hosts.end());
}

void SchedulingDecision::print()
{
SPDLOG_DEBUG("-------------- Decision for App: {} ----------------", appId);
SPDLOG_DEBUG("MsgId\tAppId\tGroupId\tGrIdx\tHostIp");
// Modulo a big number so that we can get the UUIDs to fit within one tab
int formatBase = 1e6;
for (int i = 0; i < hosts.size(); i++) {
SPDLOG_DEBUG("{}\t{}\t{}\t{}\t{}",
messageIds.at(i) % formatBase,
appId % formatBase,
groupId % formatBase,
groupIdxs.at(i),
hosts.at(i));
}
SPDLOG_DEBUG("------------- End Decision for App {} ---------------",
appId);
}
}
3 changes: 3 additions & 0 deletions tests/test/batch-scheduler/test_scheduling_decisions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ TEST_CASE_METHOD(ConfFixture, "Test building scheduling decisions", "[util]")
REQUIRE(newDecision == decision);
newDecision.groupId = 1338;
REQUIRE(newDecision != decision);

// We can print scheduling decisions
REQUIRE_NOTHROW(decision.print());
}

TEST_CASE("Test converting point-to-point mappings to scheduling decisions",
Expand Down

0 comments on commit c725c04

Please sign in to comment.