CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
ThroughputService Class Reference

#include <ThroughputService.h>

Public Types

typedef dqm::reco::DQMStore DQMStore
 

Public Member Functions

 ThroughputService (const edm::ParameterSet &, edm::ActivityRegistry &)
 
 ~ThroughputService ()=default
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

void postEndJob ()
 
void postEvent (edm::StreamContext const &sc)
 
void preallocate (edm::service::SystemBounds const &bounds)
 
void preGlobalBeginRun (edm::GlobalContext const &gc)
 
void preSourceEvent (edm::StreamID sid)
 

Private Attributes

std::atomic< uint32_t > m_counter
 
const bool m_dqm_bynproc
 
std::string m_dqm_path
 
bool m_enable_dqm
 
tbb::concurrent_vector< std::chrono::system_clock::time_point > m_events
 
bool m_print_event_summary
 
const uint32_t m_resolution
 
dqm::reco::MonitorElementm_retired_events
 
dqm::reco::MonitorElementm_sourced_events
 
std::chrono::system_clock::time_point m_startup
 
const double m_time_range
 
const double m_time_resolution
 

Detailed Description

Definition at line 30 of file ThroughputService.h.

Member Typedef Documentation

◆ DQMStore

Definition at line 32 of file ThroughputService.h.

Constructor & Destructor Documentation

◆ ThroughputService()

ThroughputService::ThroughputService ( const edm::ParameterSet config,
edm::ActivityRegistry registry 
)

Definition at line 33 of file ThroughputService.cc.

34  : // startup time
36  // configuration
37  m_resolution(config.getUntrackedParameter<uint32_t>("eventResolution")),
38  m_counter(0),
39  m_events(config.getUntrackedParameter<uint32_t>("eventRange") / m_resolution), // allocate initial size
40  m_print_event_summary(config.getUntrackedParameter<bool>("printEventSummary")),
41  m_enable_dqm(config.getUntrackedParameter<bool>("enableDQM")),
42  m_dqm_bynproc(m_enable_dqm ? config.getUntrackedParameter<bool>("dqmPathByProcesses") : false),
43  m_dqm_path(m_enable_dqm ? config.getUntrackedParameter<std::string>("dqmPath") : ""),
44  m_time_range(m_enable_dqm ? config.getUntrackedParameter<double>("timeRange") : 0.),
45  m_time_resolution(m_enable_dqm ? config.getUntrackedParameter<double>("timeResolution") : 0.) {
46  m_events.clear(); // erases all elements, but does not free internal arrays
51 }

References m_events, postEndJob(), postEvent(), preGlobalBeginRun(), preSourceEvent(), edm::ActivityRegistry::watchPostEndJob(), edm::ActivityRegistry::watchPostEvent(), edm::ActivityRegistry::watchPreGlobalBeginRun(), and edm::ActivityRegistry::watchPreSourceEvent().

◆ ~ThroughputService()

ThroughputService::~ThroughputService ( )
default

Member Function Documentation

◆ fillDescriptions()

void ThroughputService::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 17 of file ThroughputService.cc.

17  {
19  desc.addUntracked<uint32_t>("eventRange", 10000)->setComment("Preallocate a buffer for N events");
20  desc.addUntracked<uint32_t>("eventResolution", 1)->setComment("Sample the processing time every N events");
21  desc.addUntracked<bool>("printEventSummary", false);
22  desc.ifValue(edm::ParameterDescription<bool>("enableDQM", true, false), // "false" means untracked
23  // parameters if "enableDQM" is "true"
24  true >> (edm::ParameterDescription<bool>("dqmPathByProcesses", false, false) and
25  edm::ParameterDescription<std::string>("dqmPath", "HLT/Throughput", false) and
26  edm::ParameterDescription<double>("timeRange", 60000.0, false) and
27  edm::ParameterDescription<double>("timeResolution", 10.0, false)) or
28  // parameters if "enableDQM" is "false"
29  false >> edm::EmptyGroupDescription());
30  descriptions.add("ThroughputService", desc);
31 }

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::addUntracked(), edm::ParameterSetDescription::ifValue(), and or.

◆ postEndJob()

void ThroughputService::postEndJob ( )
private

Definition at line 116 of file ThroughputService.cc.

116  {
117  if (m_counter < 2 * m_resolution) {
118  // not enough mesurements to estimate the throughput
119  edm::LogWarning("ThroughputService") << "Not enough events to measure the throughput with a resolution of "
120  << m_resolution << " events";
121  return;
122  }
123 
124  edm::LogInfo info("ThroughputService");
125 
126  if (m_print_event_summary) {
127  for (uint32_t i = 0; i < m_events.size(); ++i) {
128  info << std::setw(8) << (i + 1) * m_resolution << ", " << std::setprecision(6) << edm::TimeOfDay(m_events[i])
129  << "\n";
130  }
131  info << '\n';
132  }
133 
134  // measure the time to process each block of m_resolution events
135  uint32_t blocks = m_counter / m_resolution - 1;
136  std::vector<double> delta(blocks);
137  for (uint32_t i = 0; i < blocks; ++i) {
138  delta[i] = std::chrono::duration_cast<std::chrono::duration<double>>(m_events[i + 1] - m_events[i]).count();
139  }
140  // measure the average and standard deviation of the time to process m_resolution
141  double time_avg = TMath::Mean(delta.begin(), delta.begin() + blocks);
142  double time_dev = TMath::StdDev(delta.begin(), delta.begin() + blocks);
143  // compute the throughput and its standard deviation across the job
144  double throughput_avg = double(m_resolution) / time_avg;
145  double throughput_dev = double(m_resolution) * time_dev / time_avg / time_avg;
146 
147  info << "Average throughput: " << throughput_avg << " ± " << throughput_dev << " ev/s";
148 }

References gather_cfg::blocks, KineDebug3::count(), dumpMFGeometry_cfg::delta, mps_fire::i, info(), m_counter, m_events, m_print_event_summary, m_resolution, and Mean.

Referenced by ThroughputService().

◆ postEvent()

void ThroughputService::postEvent ( edm::StreamContext const &  sc)
private

Definition at line 104 of file ThroughputService.cc.

104  {
106  auto interval = std::chrono::duration_cast<std::chrono::duration<double>>(timestamp - m_startup).count();
107  if (m_enable_dqm) {
109  }
110  ++m_counter;
111  if (m_counter % m_resolution == 0) {
112  m_events.push_back(timestamp);
113  }
114 }

References KineDebug3::count(), dqm::impl::MonitorElement::Fill(), readEcalDQMStatus::interval, m_counter, m_enable_dqm, m_events, m_resolution, m_retired_events, m_startup, fileCollector::now, and cond::timestamp.

Referenced by ThroughputService().

◆ preallocate()

void ThroughputService::preallocate ( edm::service::SystemBounds const &  bounds)
private

Definition at line 53 of file ThroughputService.cc.

53  {
54  auto concurrent_streams = bounds.maxNumberOfStreams();
55  auto concurrent_threads = bounds.maxNumberOfThreads();
56 
58  m_dqm_path += (boost::format("/Running on %s with %d streams on %d threads") % processor_model %
59  concurrent_streams % concurrent_threads)
60  .str();
61 }

References dqm-mbProfile::format, m_dqm_bynproc, m_dqm_path, m_enable_dqm, edm::service::SystemBounds::maxNumberOfStreams(), edm::service::SystemBounds::maxNumberOfThreads(), processor_model, and str.

◆ preGlobalBeginRun()

void ThroughputService::preGlobalBeginRun ( edm::GlobalContext const &  gc)
private

Definition at line 63 of file ThroughputService.cc.

63  {
64  // if the DQMStore is available, book the DQM histograms
65  // check that the DQMStore service is available
66  if (m_enable_dqm and not edm::Service<dqm::legacy::DQMStore>().isAvailable()) {
67  // the DQMStore is not available, disable all DQM plots
68  m_enable_dqm = false;
69  edm::LogWarning("ThroughputService") << "The DQMStore is not avalable, the DQM plots will not be generated";
70  }
71 
72  if (m_enable_dqm) {
73  std::string y_axis_title = (boost::format("events / %g s") % m_time_resolution).str();
74  unsigned int bins = std::round(m_time_range / m_time_resolution);
75  double range = bins * m_time_resolution;
76 
77  // define a callback that can book the histograms
78  auto bookTransactionCallback = [&, this](DQMStore::IBooker& booker, DQMStore::IGetter&) {
79  booker.setCurrentFolder(m_dqm_path);
80  m_sourced_events = booker.book1D("throughput_sourced", "Throughput (sourced events)", bins, 0., range);
81  m_sourced_events->setXTitle("time [s]");
82  m_sourced_events->setYTitle(y_axis_title);
83  m_retired_events = booker.book1D("throughput_retired", "Throughput (retired events)", bins, 0., range);
84  m_retired_events->setXTitle("time [s]");
85  m_retired_events->setYTitle(y_axis_title);
86  };
87 
88  // book MonitorElement's for this run
89  edm::Service<DQMStore>()->meBookerGetter(bookTransactionCallback);
90  } else {
91  m_sourced_events = nullptr;
92  m_retired_events = nullptr;
93  }
94 }

References trigObjTnPSource_cfi::bins, dqm::implementation::IBooker::book1D(), dqm-mbProfile::format, m_dqm_path, m_enable_dqm, m_retired_events, m_sourced_events, m_time_range, m_time_resolution, FastTimerService_cff::range, dqm::implementation::NavigatorBase::setCurrentFolder(), dqm::impl::MonitorElement::setXTitle(), dqm::impl::MonitorElement::setYTitle(), str, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by ThroughputService().

◆ preSourceEvent()

void ThroughputService::preSourceEvent ( edm::StreamID  sid)
private

Definition at line 96 of file ThroughputService.cc.

96  {
98  auto interval = std::chrono::duration_cast<std::chrono::duration<double>>(timestamp - m_startup).count();
99  if (m_enable_dqm) {
101  }
102 }

References KineDebug3::count(), dqm::impl::MonitorElement::Fill(), readEcalDQMStatus::interval, m_enable_dqm, m_sourced_events, m_startup, fileCollector::now, and cond::timestamp.

Referenced by ThroughputService().

Member Data Documentation

◆ m_counter

std::atomic<uint32_t> ThroughputService::m_counter
private

Definition at line 55 of file ThroughputService.h.

Referenced by postEndJob(), and postEvent().

◆ m_dqm_bynproc

const bool ThroughputService::m_dqm_bynproc
private

Definition at line 61 of file ThroughputService.h.

Referenced by preallocate().

◆ m_dqm_path

std::string ThroughputService::m_dqm_path
private

Definition at line 62 of file ThroughputService.h.

Referenced by preallocate(), and preGlobalBeginRun().

◆ m_enable_dqm

bool ThroughputService::m_enable_dqm
private

Definition at line 60 of file ThroughputService.h.

Referenced by postEvent(), preallocate(), preGlobalBeginRun(), and preSourceEvent().

◆ m_events

tbb::concurrent_vector<std::chrono::system_clock::time_point> ThroughputService::m_events
private

Definition at line 56 of file ThroughputService.h.

Referenced by postEndJob(), postEvent(), and ThroughputService().

◆ m_print_event_summary

bool ThroughputService::m_print_event_summary
private

Definition at line 57 of file ThroughputService.h.

Referenced by postEndJob().

◆ m_resolution

const uint32_t ThroughputService::m_resolution
private

Definition at line 54 of file ThroughputService.h.

Referenced by postEndJob(), and postEvent().

◆ m_retired_events

dqm::reco::MonitorElement* ThroughputService::m_retired_events
private

Definition at line 49 of file ThroughputService.h.

Referenced by postEvent(), and preGlobalBeginRun().

◆ m_sourced_events

dqm::reco::MonitorElement* ThroughputService::m_sourced_events
private

Definition at line 48 of file ThroughputService.h.

Referenced by preGlobalBeginRun(), and preSourceEvent().

◆ m_startup

std::chrono::system_clock::time_point ThroughputService::m_startup
private

Definition at line 51 of file ThroughputService.h.

Referenced by postEvent(), and preSourceEvent().

◆ m_time_range

const double ThroughputService::m_time_range
private

Definition at line 63 of file ThroughputService.h.

Referenced by preGlobalBeginRun().

◆ m_time_resolution

const double ThroughputService::m_time_resolution
private

Definition at line 64 of file ThroughputService.h.

Referenced by preGlobalBeginRun().

ThroughputService::m_time_range
const double m_time_range
Definition: ThroughputService.h:63
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
mps_fire.i
i
Definition: mps_fire.py:355
edm::TimeOfDay
Definition: TimeOfDay.h:9
ThroughputService::m_sourced_events
dqm::reco::MonitorElement * m_sourced_events
Definition: ThroughputService.h:48
ThroughputService::m_resolution
const uint32_t m_resolution
Definition: ThroughputService.h:54
edm::LogInfo
Definition: MessageLogger.h:254
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
ThroughputService::postEvent
void postEvent(edm::StreamContext const &sc)
Definition: ThroughputService.cc:104
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:152
ThroughputService::postEndJob
void postEndJob()
Definition: ThroughputService.cc:116
ThroughputService::preGlobalBeginRun
void preGlobalBeginRun(edm::GlobalContext const &gc)
Definition: ThroughputService.cc:63
ThroughputService::m_retired_events
dqm::reco::MonitorElement * m_retired_events
Definition: ThroughputService.h:49
ThroughputService::m_dqm_path
std::string m_dqm_path
Definition: ThroughputService.h:62
ThroughputService::preSourceEvent
void preSourceEvent(edm::StreamID sid)
Definition: ThroughputService.cc:96
Mean
Definition: SiPixelActionExecutor.h:21
ThroughputService::m_print_event_summary
bool m_print_event_summary
Definition: ThroughputService.h:57
config
Definition: config.py:1
fileCollector.now
now
Definition: fileCollector.py:207
ThroughputService::m_events
tbb::concurrent_vector< std::chrono::system_clock::time_point > m_events
Definition: ThroughputService.h:56
dqm::legacy::DQMStore::IBooker
dqm::implementation::IBooker IBooker
Definition: DQMStore.h:729
cond::timestamp
Definition: Time.h:19
edm::ActivityRegistry::watchPostEndJob
void watchPostEndJob(PostEndJob::slot_type const &iSlot)
Definition: ActivityRegistry.h:168
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
dqm-mbProfile.format
format
Definition: dqm-mbProfile.py:16
dqm::impl::MonitorElement::Fill
void Fill(long long x)
Definition: MonitorElement.h:290
str
#define str(s)
Definition: TestProcessor.cc:48
dqm::impl::MonitorElement::setXTitle
virtual void setXTitle(std::string const &title)
Definition: MonitorElement.cc:861
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::LogWarning
Definition: MessageLogger.h:141
edm::ParameterSetDescription::addUntracked
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:100
edm::ActivityRegistry::watchPostEvent
void watchPostEvent(PostEvent::slot_type const &iSlot)
Definition: ActivityRegistry.h:406
KineDebug3::count
void count()
Definition: KinematicConstrainedVertexUpdatorT.h:21
dumpMFGeometry_cfg.delta
delta
Definition: dumpMFGeometry_cfg.py:25
edm::ParameterSetDescription::ifValue
ParameterDescriptionNode * ifValue(ParameterDescription< T > const &switchParameter, std::unique_ptr< ParameterDescriptionCases< T >> cases)
Definition: ParameterSetDescription.h:220
edm::Service
Definition: Service.h:30
dqm::impl::MonitorElement::setYTitle
virtual void setYTitle(std::string const &title)
Definition: MonitorElement.cc:866
readEcalDQMStatus.interval
interval
Definition: readEcalDQMStatus.py:18
ThroughputService::m_enable_dqm
bool m_enable_dqm
Definition: ThroughputService.h:60
ThroughputService::m_counter
std::atomic< uint32_t > m_counter
Definition: ThroughputService.h:55
ThroughputService::m_time_resolution
const double m_time_resolution
Definition: ThroughputService.h:64
edm::ActivityRegistry::watchPreSourceEvent
void watchPreSourceEvent(PreSourceEvent::slot_type const &iSlot)
Definition: ActivityRegistry.h:182
or
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
ThroughputService::m_dqm_bynproc
const bool m_dqm_bynproc
Definition: ThroughputService.h:61
ThroughputService::m_startup
std::chrono::system_clock::time_point m_startup
Definition: ThroughputService.h:51
edm::ActivityRegistry::watchPreGlobalBeginRun
void watchPreGlobalBeginRun(PreGlobalBeginRun::slot_type const &iSlot)
Definition: ActivityRegistry.h:273
trigObjTnPSource_cfi.bins
bins
Definition: trigObjTnPSource_cfi.py:20
processor_model
const std::string processor_model
Definition: processor_model.cc:47
dqm::legacy::DQMStore::IGetter
dqm::implementation::IGetter IGetter
Definition: DQMStore.h:730
edm::EmptyGroupDescription
Definition: EmptyGroupDescription.h:15
edm::ParameterDescription
Definition: ParameterDescription.h:110
gather_cfg.blocks
blocks
Definition: gather_cfg.py:90