Skip to content

Commit

Permalink
planner: add info logging around migration opportunities
Browse files Browse the repository at this point in the history
  • Loading branch information
csegarragonz committed Sep 5, 2023
1 parent f08dcf7 commit 3e77da3
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 18 deletions.
2 changes: 1 addition & 1 deletion include/faabric/batch-scheduler/SchedulingDecision.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class SchedulingDecision

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

void print();
void print(const std::string& logLevel = "debug");
};

}
36 changes: 25 additions & 11 deletions src/batch-scheduler/SchedulingDecision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,35 @@ std::set<std::string> SchedulingDecision::uniqueHosts()
return std::set<std::string>(hosts.begin(), hosts.end());
}

void SchedulingDecision::print()
void SchedulingDecision::print(const std::string& logLevel)
{
SPDLOG_DEBUG("-------------- Decision for App: {} ----------------", appId);
SPDLOG_DEBUG("MsgId\tAppId\tGroupId\tGrIdx\tHostIp");
std::string printedText;
printedText += fmt::format(
"-------------- Decision for App: {} ----------------\n", appId);
printedText += "MsgId\tAppId\tGroupId\tGrIdx\tHostIp\n";
// 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));
printedText += fmt::format("{}\t{}\t{}\t{}\t{}\n",
messageIds.at(i) % formatBase,
appId % formatBase,
groupId % formatBase,
groupIdxs.at(i),
hosts.at(i));
}
printedText += fmt::format(
"------------- End Decision for App {} ---------------", appId);

if (logLevel == "debug") {
SPDLOG_DEBUG(printedText);
} else if (logLevel == "info") {
SPDLOG_INFO(printedText);
} else if (logLevel == "warn") {
SPDLOG_WARN(printedText);
} else if (logLevel == "error") {
SPDLOG_ERROR(printedText);
} else {
SPDLOG_ERROR("Unrecognised log level: {}", logLevel);

Check warning on line 90 in src/batch-scheduler/SchedulingDecision.cpp

View check run for this annotation

Codecov / codecov/patch

src/batch-scheduler/SchedulingDecision.cpp#L86-L90

Added lines #L86 - L90 were not covered by tests
}
SPDLOG_DEBUG("------------- End Decision for App {} ---------------",
appId);
}
}
16 changes: 10 additions & 6 deletions src/planner/Planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ Planner::callBatch(std::shared_ptr<BatchExecuteRequest> req)
// on the old decision (we don't care the one we send), so we make sure
// we are scheduling the same messages from the old request
if (decisionType == faabric::batch_scheduler::DecisionType::DIST_CHANGE) {
SPDLOG_INFO("App {} asked for migration opportunities");
auto oldReq = state.inFlightReqs.at(appId).first;
req->clear_messages();
for (const auto& msg : oldReq->messages()) {
Expand All @@ -425,7 +426,7 @@ Planner::callBatch(std::shared_ptr<BatchExecuteRequest> req)
}

if (*decision == DO_NOT_MIGRATE_DECISION) {
SPDLOG_DEBUG("Decided to not migrate app: {}", appId);
SPDLOG_INFO("Decided to not migrate app: {}", appId);
return decision;
}

Expand Down Expand Up @@ -493,14 +494,17 @@ Planner::callBatch(std::shared_ptr<BatchExecuteRequest> req)
break;
}
case faabric::batch_scheduler::DecisionType::DIST_CHANGE: {
// 0. Log the decision in debug mode
#ifndef NDEBUG
decision->print();
#endif

auto oldReq = state.inFlightReqs.at(appId).first;
auto oldDec = state.inFlightReqs.at(appId).second;

// 0. For the time being, when migrating we always print both
// decisions (old and new)
SPDLOG_INFO("Decided to migrate app {}!", appId);
SPDLOG_INFO("Old decision:");
oldDec->print("info");
SPDLOG_INFO("New decision:");
decision->print("info");

// We want to let all hosts involved in the migration (not only
// those in the new decision) that we are gonna migrate. For the
// evicted hosts (those present in the old decision but not in the
Expand Down

0 comments on commit 3e77da3

Please sign in to comment.