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

Improve early unlocking in FastMonitoringService [12.3.x] #38585

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 24 additions & 22 deletions EventFilter/Utilities/src/FastMonitoringService.cc
Expand Up @@ -762,7 +762,7 @@ namespace evf {
while (!fmt_->m_stoprequest) {
std::vector<std::vector<unsigned int>> lastEnc;
{
std::lock_guard<std::mutex> lock(fmt_->monlock_);
std::unique_lock<std::mutex> lock(fmt_->monlock_);

doSnapshot(lastGlobalLumi_, false);

Expand All @@ -775,40 +775,42 @@ namespace evf {
for (unsigned int i = 0; i < nStreams_; i++) {
CSVv.push_back(fmt_->jsonMonitor_->getCSVString((int)i));
}
fmt_->monlock_.unlock();
// release mutex before writing out fast path file
lock.release()->unlock();
for (unsigned int i = 0; i < nStreams_; i++) {
if (!CSVv[i].empty())
fmt_->jsonMonitor_->outputCSV(fastPathList_[i], CSVv[i]);
}
} else {
std::string CSV = fmt_->jsonMonitor_->getCSVString();
//release mutex before writing out fast path file
fmt_->monlock_.unlock();
// release mutex before writing out fast path file
lock.release()->unlock();
if (!CSV.empty())
fmt_->jsonMonitor_->outputCSV(fastPath_, CSV);
}
}
snapCounter_++;
}

std::stringstream accum;
std::function<void(std::vector<unsigned int>)> f = [&](std::vector<unsigned int> p) {
for (unsigned int i = 0; i < nStreams_; i++) {
if (i == 0)
accum << "[" << p[i] << ",";
else if (i <= nStreams_ - 1)
accum << p[i] << ",";
else
accum << p[i] << "]";
}
};

accum << "Current states: Ms=" << fmt_->m_data.fastMacrostateJ_.value() << " ms=";
f(lastEnc[0]);
accum << " us=";
f(lastEnc[1]);
accum << " is=" << inputStateNames[inputState_] << " iss=" << inputStateNames[inputSupervisorState_];
edm::LogInfo("FastMonitoringService") << accum.str();
{
edm::LogInfo msg("FastMonitoringService");
auto f = [&](std::vector<unsigned int> const& p) {
for (unsigned int i = 0; i < nStreams_; i++) {
if (i == 0)
msg << "[" << p[i] << ",";
else if (i <= nStreams_ - 1)
msg << p[i] << ",";
else
msg << p[i] << "]";
}
};

msg << "Current states: Ms=" << fmt_->m_data.fastMacrostateJ_.value() << " ms=";
f(lastEnc[0]);
msg << " us=";
f(lastEnc[1]);
msg << " is=" << inputStateNames[inputState_] << " iss=" << inputStateNames[inputSupervisorState_];
}

::sleep(sleepTime_);
}
Expand Down