Skip to content

Commit

Permalink
Merge pull request #40062 from fwyzard/fix_ThroughputService_and_Fast…
Browse files Browse the repository at this point in the history
…TimerService_DQM_folders

Fix the `ThroughputService` and `FastTimerService` DQM folders
  • Loading branch information
cmsbuild committed Nov 15, 2022
2 parents edb4347 + 27815f8 commit 6b6a010
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
10 changes: 10 additions & 0 deletions HLTrigger/Timer/plugins/ThroughputService.cc
Expand Up @@ -13,6 +13,8 @@
#include "HLTrigger/Timer/interface/processor_model.h"
#include "ThroughputService.h"

using namespace std::literals;

// describe the module's configuration
void ThroughputService::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
Expand Down Expand Up @@ -44,6 +46,7 @@ ThroughputService::ThroughputService(const edm::ParameterSet& config, edm::Activ
m_time_range(m_enable_dqm ? config.getUntrackedParameter<double>("timeRange") : 0.),
m_time_resolution(m_enable_dqm ? config.getUntrackedParameter<double>("timeResolution") : 0.) {
m_events.clear(); // erases all elements, but does not free internal arrays
registry.watchPreallocate(this, &ThroughputService::preallocate);
registry.watchPreGlobalBeginRun(this, &ThroughputService::preGlobalBeginRun);
registry.watchPreSourceEvent(this, &ThroughputService::preSourceEvent);
registry.watchPostEvent(this, &ThroughputService::postEvent);
Expand Down Expand Up @@ -73,6 +76,13 @@ void ThroughputService::preGlobalBeginRun(edm::GlobalContext const& gc) {
unsigned int bins = std::round(m_time_range / m_time_resolution);
double range = bins * m_time_resolution;

// clean characters that are deemed unsafe for DQM
// see the definition of `s_safe` in DQMServices/Core/src/DQMStore.cc
auto safe_for_dqm = "/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-+=_()# "s;
for (auto& c : m_dqm_path)
if (safe_for_dqm.find(c) == std::string::npos)
c = '_';

// define a callback that can book the histograms
auto bookTransactionCallback = [&, this](DQMStore::IBooker& booker, DQMStore::IGetter&) {
booker.setCurrentFolder(m_dqm_path);
Expand Down
18 changes: 14 additions & 4 deletions HLTrigger/Timer/src/processor_model.cc
Expand Up @@ -16,8 +16,11 @@
#include "HLTrigger/Timer/interface/processor_model.h"

std::string read_processor_model() {
std::string result = "unknown";

#if BOOST_OS_LINUX
// on Linux, read the processor model from /proc/cpuinfo
// on Linux, read the processor model from /proc/cpuinfo,
// and check the status of SMT from /sys/devices/system/cpu/smt/active
static const std::regex pattern("^model name\\s*:\\s*(.*)", std::regex::optimize);
std::smatch match;

Expand All @@ -26,9 +29,17 @@ std::string read_processor_model() {
while (cpuinfo.good()) {
std::getline(cpuinfo, line);
if (std::regex_match(line, match, pattern)) {
return match[1];
result = match[1];
break;
}
}

std::ifstream smtinfo("/sys/devices/system/cpu/smt/active", std::ios::in);
if (smtinfo) {
int status;
smtinfo >> status;
result += status ? " with SMT enabled" : " with SMT disabled";
}
#endif // BOOST_OS_LINUX

#if BOOST_OS_BSD || BOOST_OS_MACOS
Expand All @@ -38,10 +49,9 @@ std::string read_processor_model() {
sysctlbyname("machdep.cpu.brand_string", nullptr, &len, NULL, 0);
result.resize(len);
sysctlbyname("machdep.cpu.brand_string", result.data(), &len, NULL, 0);
return result;
#endif // BOOST_OS_BSD || BOOST_OS_MACOS

return "unknown";
return result;
}

const std::string processor_model = read_processor_model();

0 comments on commit 6b6a010

Please sign in to comment.