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

1881 LB statistics json file opened too early #1886

Merged
merged 1 commit into from
Jul 28, 2022
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
24 changes: 15 additions & 9 deletions src/vt/vrt/collection/balance/lb_invoke/lb_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -450,12 +450,6 @@ void LBManager::destroyLB() {
}
}

void LBManager::initialize() {
#if vt_check_enabled(lblite)
createStatisticsFile();
#endif
}

void LBManager::finalize() {
closeStatisticsFile();
}
Expand Down Expand Up @@ -548,13 +542,17 @@ void LBManager::statsHandler(StatsMsgType* msg) {

void LBManager::stagePreLBStatistics(const StatisticMapType &statistics) {
// Statistics output when LB is enabled and appropriate flag is enabled
if (!theConfig()->vt_lb_statistics) {
if (theContext()->getNode() != 0 or !theConfig()->vt_lb_statistics) {
return;
}

nlohmann::json j;
j["pre-LB"] = lb::jsonifyPhaseStatistics(statistics);

if (!statistics_writer_) {
createStatisticsFile();
}

using JSONAppender = util::json::Appender<std::ofstream>;
auto writer = static_cast<JSONAppender*>(statistics_writer_.get());
writer->stageObject(j);
Expand All @@ -564,22 +562,26 @@ void LBManager::stagePostLBStatistics(
const StatisticMapType &statistics, int32_t migration_count
) {
// Statistics output when LB is enabled and appropriate flag is enabled
if (!theConfig()->vt_lb_statistics) {
if (theContext()->getNode() != 0 or !theConfig()->vt_lb_statistics) {
return;
}

nlohmann::json j;
j["post-LB"] = lb::jsonifyPhaseStatistics(statistics);
j["migration count"] = migration_count;

if (!statistics_writer_) {
createStatisticsFile();
}

using JSONAppender = util::json::Appender<std::ofstream>;
auto writer = static_cast<JSONAppender*>(statistics_writer_.get());
writer->stageObject(j);
}

void LBManager::commitPhaseStatistics(PhaseType phase) {
// Statistics output when LB is enabled and appropriate flag is enabled
if (!theConfig()->vt_lb_statistics) {
if (theContext()->getNode() != 0 or !theConfig()->vt_lb_statistics) {
return;
}

Expand All @@ -591,6 +593,10 @@ void LBManager::commitPhaseStatistics(PhaseType phase) {
nlohmann::json j;
j["id"] = phase;

if (!statistics_writer_) {
createStatisticsFile();
}

using JSONAppender = util::json::Appender<std::ofstream>;
auto writer = static_cast<JSONAppender*>(statistics_writer_.get());
writer->stageObject(j);
Expand Down
1 change: 0 additions & 1 deletion src/vt/vrt/collection/balance/lb_invoke/lb_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ struct LBManager : runtime::component::Component<LBManager> {
std::string name() override { return "LBManager"; }

void startup() override;
void initialize() override;
void finalize() override;
void fatalError() override;

Expand Down