CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
edm::service::Timing Class Reference
Inheritance diagram for edm::service::Timing:
edm::TimingServiceBase

Classes

struct  CountAndTime
 

Public Member Functions

void addToCPUTime (double iTime) override
 
double getTotalCPU () const override
 
 Timing (ParameterSet const &, ActivityRegistry &)
 
 ~Timing () override
 
- Public Member Functions inherited from edm::TimingServiceBase
 TimingServiceBase ()
 
virtual ~TimingServiceBase ()
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::TimingServiceBase
static void jobStarted ()
 
static double jobStartTime ()
 

Private Member Functions

void accumulateTimeBegin (std::atomic< CountAndTime * > &countAndTime, double &accumulatedTime)
 
void accumulateTimeEnd (std::atomic< CountAndTime * > &countAndTime, double &accumulatedTime)
 
void lastPostEvent (double curr_event_time, unsigned int index, StreamContext const &iStream)
 
void postBeginJob ()
 
double postCommon () const
 
void postEndJob ()
 
void postEvent (StreamContext const &)
 
void postEventSetupGet (eventsetup::ComponentDescription const *, eventsetup::EventSetupRecordKey const &, eventsetup::DataKey const &)
 
void postGlobalBeginLumi (GlobalContext const &)
 
void postGlobalBeginRun (GlobalContext const &)
 
void postLockEventSetupGet (eventsetup::ComponentDescription const *, eventsetup::EventSetupRecordKey const &, eventsetup::DataKey const &)
 
void postModule (ModuleDescription const &md)
 
void postModuleEvent (StreamContext const &, ModuleCallingContext const &)
 
void postModuleGlobal (GlobalContext const &, ModuleCallingContext const &)
 
void postModuleStream (StreamContext const &, ModuleCallingContext const &)
 
void postOpenFile (std::string const &, bool)
 
void postSourceEvent (StreamID)
 
void postSourceLumi (LuminosityBlockIndex)
 
void postSourceRun (RunIndex)
 
void preBeginJob (PathsAndConsumesOfModulesBase const &, ProcessContext const &)
 
void preEvent (StreamContext const &)
 
void preLockEventSetupGet (eventsetup::ComponentDescription const *, eventsetup::EventSetupRecordKey const &, eventsetup::DataKey const &)
 
void preModule (ModuleDescription const &md)
 
void preModuleGlobal (GlobalContext const &, ModuleCallingContext const &)
 
void preModuleStream (StreamContext const &, ModuleCallingContext const &)
 
void preOpenFile (std::string const &, bool)
 
void preSourceEvent (StreamID)
 
void preSourceLumi (LuminosityBlockIndex)
 
void preSourceRun (RunIndex)
 

Private Attributes

double accumulatedTimeForGet_
 
double accumulatedTimeForLock_
 
std::atomic< unsigned long > begin_lumi_count_
 
std::atomic< unsigned long > begin_run_count_
 
bool configuredInTopLevelProcess_
 
std::atomic< CountAndTime * > countAndTimeForGet_
 
std::atomic< CountAndTime * > countAndTimeForLock_
 
CountAndTime countAndTimeZero_
 
std::vector< std::unique_ptr< std::atomic< unsigned int > > > countSubProcessesPostEvent_
 
std::vector< std::unique_ptr< std::atomic< unsigned int > > > countSubProcessesPreEvent_
 
std::vector< double > curr_events_time_
 
double curr_job_cpu_
 
double curr_job_time_
 
std::atomic< double > extra_job_cpu_
 
std::atomic< double > last_run_cpu_
 
std::atomic< double > last_run_time_
 
std::vector< double > max_events_time_
 
std::vector< double > min_events_time_
 
unsigned int nStreams_
 
unsigned int nSubProcesses_
 
unsigned int nThreads_
 
bool report_summary_
 
std::vector< double > sum_events_time_
 
bool summary_only_
 
double threshold_
 
std::atomic< unsigned long > total_event_count_
 

Detailed Description

Definition at line 46 of file Timing.cc.

Constructor & Destructor Documentation

edm::service::Timing::Timing ( ParameterSet const &  iPS,
ActivityRegistry iRegistry 
)

Definition at line 219 of file Timing.cc.

220  : curr_job_time_(0.),
221  curr_job_cpu_(0.),
222  extra_job_cpu_(0.0),
223  last_run_time_(0.0),
224  last_run_cpu_(0.0),
226  summary_only_(iPS.getUntrackedParameter<bool>("summaryOnly")),
227  report_summary_(iPS.getUntrackedParameter<bool>("useJobReport")),
228  threshold_(iPS.getUntrackedParameter<double>("excessiveTimeThreshold")),
233  begin_run_count_(0),
234  countAndTimeZero_{0, 0.0},
240  nSubProcesses_{0} {
241  iRegistry.watchPreBeginJob(this, &Timing::preBeginJob);
242  iRegistry.watchPostBeginJob(this, &Timing::postBeginJob);
243  iRegistry.watchPostEndJob(this, &Timing::postEndJob);
244 
245  iRegistry.watchPreEvent(this, &Timing::preEvent);
246  iRegistry.watchPostEvent(this, &Timing::postEvent);
247 
248  iRegistry.watchPreLockEventSetupGet(this, &Timing::preLockEventSetupGet);
249  iRegistry.watchPostLockEventSetupGet(this, &Timing::postLockEventSetupGet);
250  iRegistry.watchPostEventSetupGet(this, &Timing::postEventSetupGet);
251 
252  bool checkThreshold = true;
253  if (threshold_ <= 0.0) {
254  //we need to ignore the threshold check
256  checkThreshold = false;
257  }
258 
259  if ((not summary_only_) || (checkThreshold)) {
260  iRegistry.watchPreModuleEvent(this, &Timing::preModuleStream);
261  iRegistry.watchPostModuleEvent(this, &Timing::postModuleEvent);
262  }
263  if (checkThreshold) {
264  iRegistry.watchPreSourceEvent(this, &Timing::preSourceEvent);
265  iRegistry.watchPostSourceEvent(this, &Timing::postSourceEvent);
266 
267  iRegistry.watchPreSourceLumi(this, &Timing::preSourceLumi);
268  iRegistry.watchPostSourceLumi(this, &Timing::postSourceLumi);
269 
270  iRegistry.watchPreSourceRun(this, &Timing::preSourceRun);
271  iRegistry.watchPostSourceRun(this, &Timing::postSourceRun);
272 
273  iRegistry.watchPreOpenFile(this, &Timing::preOpenFile);
274  iRegistry.watchPostOpenFile(this, &Timing::postOpenFile);
275 
276  iRegistry.watchPreEventReadFromSource(this, &Timing::preModuleStream);
277  iRegistry.watchPostEventReadFromSource(this, &Timing::postModuleStream);
278 
279  iRegistry.watchPreModuleConstruction(this, &Timing::preModule);
280  iRegistry.watchPostModuleConstruction(this, &Timing::postModule);
281 
282  iRegistry.watchPreModuleBeginJob(this, &Timing::preModule);
283  iRegistry.watchPostModuleBeginJob(this, &Timing::postModule);
284 
285  iRegistry.watchPreModuleEndJob(this, &Timing::preModule);
286  iRegistry.watchPostModuleEndJob(this, &Timing::postModule);
287 
288  iRegistry.watchPreModuleStreamBeginRun(this, &Timing::preModuleStream);
289  iRegistry.watchPostModuleStreamBeginRun(this, &Timing::postModuleStream);
290  iRegistry.watchPreModuleStreamEndRun(this, &Timing::preModuleStream);
291  iRegistry.watchPostModuleStreamEndRun(this, &Timing::postModuleStream);
292 
293  iRegistry.watchPreModuleStreamBeginLumi(this, &Timing::preModuleStream);
294  iRegistry.watchPostModuleStreamBeginLumi(this, &Timing::postModuleStream);
295  iRegistry.watchPreModuleStreamEndLumi(this, &Timing::preModuleStream);
296  iRegistry.watchPostModuleStreamEndLumi(this, &Timing::postModuleStream);
297 
298  iRegistry.watchPreModuleGlobalBeginRun(this, &Timing::preModuleGlobal);
299  iRegistry.watchPostModuleGlobalBeginRun(this, &Timing::postModuleGlobal);
300  iRegistry.watchPreModuleGlobalEndRun(this, &Timing::preModuleGlobal);
301  iRegistry.watchPostModuleGlobalEndRun(this, &Timing::postModuleGlobal);
302 
303  iRegistry.watchPreModuleGlobalBeginLumi(this, &Timing::preModuleGlobal);
304  iRegistry.watchPostModuleGlobalBeginLumi(this, &Timing::postModuleGlobal);
305  iRegistry.watchPreModuleGlobalEndLumi(this, &Timing::preModuleGlobal);
306  iRegistry.watchPostModuleGlobalEndLumi(this, &Timing::postModuleGlobal);
307 
308  iRegistry.watchPreSourceConstruction(this, &Timing::preModule);
309  iRegistry.watchPostSourceConstruction(this, &Timing::postModule);
310  }
311 
312  iRegistry.watchPostGlobalBeginRun(this, &Timing::postGlobalBeginRun);
313  iRegistry.watchPostGlobalBeginLumi(this, &Timing::postGlobalBeginLumi);
314 
315  iRegistry.preallocateSignal_.connect([this](service::SystemBounds const& iBounds) {
316  nStreams_ = iBounds.maxNumberOfStreams();
317  nThreads_ = iBounds.maxNumberOfThreads();
318  curr_events_time_.resize(nStreams_, 0.);
319  sum_events_time_.resize(nStreams_, 0.);
320  max_events_time_.resize(nStreams_, 0.);
321  min_events_time_.resize(nStreams_, 1.E6);
322  for (unsigned int i = 0; i < nStreams_; ++i) {
323  countSubProcessesPreEvent_.emplace_back(std::make_unique<std::atomic<unsigned int>>(0));
324  countSubProcessesPostEvent_.emplace_back(std::make_unique<std::atomic<unsigned int>>(0));
325  }
326  });
327 
328  iRegistry.postGlobalEndRunSignal_.connect([this](edm::GlobalContext const&) {
330  last_run_cpu_ = getCPU();
331  });
332  }
std::vector< double > sum_events_time_
Definition: Timing.cc:130
double curr_job_time_
Definition: Timing.cc:115
std::atomic< double > last_run_cpu_
Definition: Timing.cc:120
std::vector< double > max_events_time_
Definition: Timing.cc:128
std::vector< double > curr_events_time_
Definition: Timing.cc:121
void postLockEventSetupGet(eventsetup::ComponentDescription const *, eventsetup::EventSetupRecordKey const &, eventsetup::DataKey const &)
Definition: Timing.cc:617
void preModule(ModuleDescription const &md)
Definition: Timing.cc:560
static double getCPU()
Definition: Timing.cc:176
void postEvent(StreamContext const &)
Definition: Timing.cc:501
void preModuleStream(StreamContext const &, ModuleCallingContext const &)
Definition: Timing.cc:588
double curr_job_cpu_
Definition: Timing.cc:116
std::atomic< unsigned long > begin_lumi_count_
Definition: Timing.cc:132
void preSourceLumi(LuminosityBlockIndex)
Definition: Timing.cc:548
unsigned int nThreads_
Definition: Timing.cc:135
void preOpenFile(std::string const &, bool)
Definition: Timing.cc:556
unsigned int nStreams_
Definition: Timing.cc:134
void preModuleGlobal(GlobalContext const &, ModuleCallingContext const &)
Definition: Timing.cc:564
void postModule(ModuleDescription const &md)
Definition: Timing.cc:562
void postGlobalBeginRun(GlobalContext const &)
Definition: Timing.cc:570
void preSourceRun(RunIndex)
Definition: Timing.cc:552
void postModuleStream(StreamContext const &, ModuleCallingContext const &)
Definition: Timing.cc:592
std::atomic< CountAndTime * > countAndTimeForGet_
Definition: Timing.cc:142
void postModuleEvent(StreamContext const &, ModuleCallingContext const &)
Definition: Timing.cc:531
std::atomic< double > last_run_time_
Definition: Timing.cc:119
void postSourceLumi(LuminosityBlockIndex)
Definition: Timing.cc:550
std::atomic< CountAndTime * > countAndTimeForLock_
Definition: Timing.cc:139
double accumulatedTimeForLock_
Definition: Timing.cc:140
void preLockEventSetupGet(eventsetup::ComponentDescription const *, eventsetup::EventSetupRecordKey const &, eventsetup::DataKey const &)
Definition: Timing.cc:608
std::vector< std::unique_ptr< std::atomic< unsigned int > > > countSubProcessesPreEvent_
Definition: Timing.cc:145
std::vector< std::unique_ptr< std::atomic< unsigned int > > > countSubProcessesPostEvent_
Definition: Timing.cc:146
void postGlobalBeginLumi(GlobalContext const &)
Definition: Timing.cc:579
std::atomic< unsigned long > begin_run_count_
Definition: Timing.cc:133
void postEventSetupGet(eventsetup::ComponentDescription const *, eventsetup::EventSetupRecordKey const &, eventsetup::DataKey const &)
Definition: Timing.cc:627
std::atomic< unsigned long > total_event_count_
Definition: Timing.cc:131
bool configuredInTopLevelProcess_
Definition: Timing.cc:148
void postSourceRun(RunIndex)
Definition: Timing.cc:554
double accumulatedTimeForGet_
Definition: Timing.cc:143
void postModuleGlobal(GlobalContext const &, ModuleCallingContext const &)
Definition: Timing.cc:568
void preBeginJob(PathsAndConsumesOfModulesBase const &, ProcessContext const &)
Definition: Timing.cc:357
CountAndTime countAndTimeZero_
Definition: Timing.cc:137
void postOpenFile(std::string const &, bool)
Definition: Timing.cc:558
static double getTime()
Definition: Timing.cc:169
void postSourceEvent(StreamID)
Definition: Timing.cc:546
std::atomic< double > extra_job_cpu_
Definition: Timing.cc:117
void preSourceEvent(StreamID)
Definition: Timing.cc:544
void preEvent(StreamContext const &)
Definition: Timing.cc:484
std::vector< double > min_events_time_
Definition: Timing.cc:129
unsigned int nSubProcesses_
Definition: Timing.cc:149
edm::service::Timing::~Timing ( )
override

Definition at line 334 of file Timing.cc.

334 {}

Member Function Documentation

void edm::service::Timing::accumulateTimeBegin ( std::atomic< CountAndTime * > &  countAndTime,
double &  accumulatedTime 
)
private

Definition at line 633 of file Timing.cc.

References edm::service::Timing::CountAndTime::count_, and edm::service::getTime().

Referenced by postLockEventSetupGet(), and preLockEventSetupGet().

633  {
634  double newTime = getTime();
635  auto newStat = std::make_unique<CountAndTime>(0, newTime);
636 
637  CountAndTime* oldStat = countAndTime.load();
638  while (true) {
639  if (oldStat == nullptr) {
640  oldStat = countAndTime.load();
641  } else if (countAndTime.compare_exchange_strong(oldStat, nullptr)) {
642  break;
643  }
644  }
645 
646  newStat->count_ = oldStat->count_ + 1;
647  if (oldStat->count_ != 0) {
648  accumulatedTime += (newTime - oldStat->time_) * oldStat->count_;
649  }
650  countAndTime.store(newStat.release());
651  if (oldStat != &countAndTimeZero_) {
652  delete oldStat;
653  }
654  }
CountAndTime countAndTimeZero_
Definition: Timing.cc:137
static double getTime()
Definition: Timing.cc:169
void edm::service::Timing::accumulateTimeEnd ( std::atomic< CountAndTime * > &  countAndTime,
double &  accumulatedTime 
)
private

Definition at line 656 of file Timing.cc.

References edm::service::Timing::CountAndTime::count_, cppFunctionSkipper::exception, edm::service::getTime(), edm::service::Timing::CountAndTime::time_, and hgcalPlots::Timing.

Referenced by postEventSetupGet(), and postLockEventSetupGet().

656  {
657  double newTime = getTime();
658 
659  CountAndTime* oldStat = countAndTime.load();
660  while (true) {
661  if (oldStat == nullptr) {
662  oldStat = countAndTime.load();
663  } else if (countAndTime.compare_exchange_strong(oldStat, nullptr)) {
664  break;
665  }
666  }
667 
668  if (oldStat->count_ == 1) {
669  accumulatedTime += newTime - oldStat->time_;
670  countAndTime.store(&countAndTimeZero_);
671  } else {
672  try {
673  auto newStat = std::make_unique<CountAndTime>(oldStat->count_ - 1, newTime);
674  accumulatedTime += (newTime - oldStat->time_) * oldStat->count_;
675  countAndTime.store(newStat.release());
676  } catch (std::exception&) {
677  countAndTime.store(oldStat);
678  throw;
679  }
680  }
681  delete oldStat;
682  }
CountAndTime countAndTimeZero_
Definition: Timing.cc:137
static double getTime()
Definition: Timing.cc:169
void edm::service::Timing::addToCPUTime ( double  iTime)
overridevirtual

Extra CPU time used by a job but not seen by cmsRun The value should be in seconds. This function is safe to call from multiple threads

Implements edm::TimingServiceBase.

Definition at line 336 of file Timing.cc.

336  {
337  //For accounting purposes we effectively can say we started earlier
338  double expected = extra_job_cpu_.load();
339  while (not extra_job_cpu_.compare_exchange_strong(expected, expected + iTime)) {
340  }
341  }
std::atomic< double > extra_job_cpu_
Definition: Timing.cc:117
void edm::service::Timing::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 345 of file Timing.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::addUntracked(), edm::ConfigurationDescriptions::setComment(), and edm::ParameterDescriptionNode::setComment().

345  {
347  desc.addUntracked<bool>("summaryOnly", false)->setComment("If 'true' do not report timing for each event");
348  desc.addUntracked<bool>("useJobReport", true)->setComment("If 'true' write summary information to JobReport");
349  desc.addUntracked<double>("excessiveTimeThreshold", 0.)
350  ->setComment(
351  "Amount of time in seconds before reporting a module or source has taken excessive time. A value of 0.0 "
352  "turns off this reporting.");
353  descriptions.add("Timing", desc);
354  descriptions.setComment("This service reports the time it takes to run each module in a job.");
355  }
void setComment(std::string const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
double edm::service::Timing::getTotalCPU ( ) const
overridevirtual

CPU time used by this process and all its children. The value returned should be in seconds.

Implements edm::TimingServiceBase.

Definition at line 343 of file Timing.cc.

References edm::service::getCPU().

343 { return getCPU(); }
static double getCPU()
Definition: Timing.cc:176
void edm::service::Timing::lastPostEvent ( double  curr_event_time,
unsigned int  index,
StreamContext const &  iStream 
)
private

Definition at line 517 of file Timing.cc.

References edm::StreamContext::eventID(), and total_event_count_.

Referenced by postEvent().

517  {
518  sum_events_time_[index] += curr_event_time;
519 
520  if (not summary_only_) {
521  auto const& eventID = iStream.eventID();
522  LogPrint("TimeEvent") << "TimeEvent> " << eventID.event() << " " << eventID.run() << " " << curr_event_time;
523  }
524  if (curr_event_time > max_events_time_[index])
525  max_events_time_[index] = curr_event_time;
526  if (curr_event_time < min_events_time_[index])
527  min_events_time_[index] = curr_event_time;
529  }
std::vector< double > sum_events_time_
Definition: Timing.cc:130
std::vector< double > max_events_time_
Definition: Timing.cc:128
std::atomic< unsigned long > total_event_count_
Definition: Timing.cc:131
std::vector< double > min_events_time_
Definition: Timing.cc:129
void edm::service::Timing::postBeginJob ( )
private

Definition at line 365 of file Timing.cc.

References edm::service::getCPU(), and edm::service::getTime().

365  {
367  return;
368  }
370  curr_job_cpu_ = getCPU();
371 
372  if (not summary_only_) {
373  LogImportant("TimeReport") << "TimeReport> Report activated"
374  << "\n"
375  << "TimeReport> Report columns headings for events: "
376  << "eventnum runnum timetaken\n"
377  << "TimeReport> Report columns headings for modules: "
378  << "eventnum runnum modulelabel modulename timetakeni\n"
379  << "TimeReport> JobTime=" << curr_job_time_ << " JobCPU=" << curr_job_cpu_ << "\n";
380  }
381  }
double curr_job_time_
Definition: Timing.cc:115
static double getCPU()
Definition: Timing.cc:176
double curr_job_cpu_
Definition: Timing.cc:116
bool configuredInTopLevelProcess_
Definition: Timing.cc:148
static double getTime()
Definition: Timing.cc:169
double edm::service::Timing::postCommon ( ) const
private

Definition at line 594 of file Timing.cc.

References edm::service::popStack(), and lumiQTWidget::t.

Referenced by postModule(), postModuleEvent(), postModuleGlobal(), postModuleStream(), postOpenFile(), postSourceEvent(), postSourceLumi(), and postSourceRun().

594  {
596  return 0.0;
597  }
598  double t = popStack();
599  if (t > threshold_) {
600  LogError("ExcessiveTime")
601  << "ExcessiveTime: Module used " << t
602  << " seconds of time which exceeds the error threshold configured in the Timing Service of " << threshold_
603  << " seconds.";
604  }
605  return t;
606  }
bool configuredInTopLevelProcess_
Definition: Timing.cc:148
static double popStack()
Definition: Timing.cc:202
void edm::service::Timing::postEndJob ( )
private

Definition at line 383 of file Timing.cc.

References curr_job_cpu_, curr_job_time_, edm::service::d2str(), extra_job_cpu_, edm::service::getCPU(), edm::service::getTime(), edm::TimingServiceBase::jobStartTime(), lumiQTWidget::t, total_event_count_, and edm::service::ui2str().

383  {
385  LogImportant("TimeReport") << "\nTimeReport> This instance of the Timing Service will be disabled because it "
386  "is configured in a SubProcess.\n"
387  << "If multiple instances of the TimingService were configured only the one in the "
388  "top level process will function.\n"
389  << "The other instance(s) will simply print this message and do nothing.\n\n";
390  return;
391  }
392 
393  const double job_end_time = getTime();
394  const double job_end_cpu = getCPU();
395  double total_job_time = job_end_time - jobStartTime();
396 
397  double total_job_cpu = job_end_cpu + extra_job_cpu_;
398 
399  const double total_initialization_time = curr_job_time_ - jobStartTime();
400  const double total_initialization_cpu = curr_job_cpu_;
401 
402  if (0.0 == jobStartTime()) {
403  //did not capture beginning time
404  total_job_time = job_end_time - curr_job_time_;
405  total_job_cpu = job_end_cpu + extra_job_cpu_ - curr_job_cpu_;
406  }
407 
408  double min_event_time = *(std::min_element(min_events_time_.begin(), min_events_time_.end()));
409  double max_event_time = *(std::max_element(max_events_time_.begin(), max_events_time_.end()));
410 
411  auto total_loop_time = last_run_time_ - curr_job_time_;
412  auto total_loop_cpu = last_run_cpu_ + extra_job_cpu_ - curr_job_cpu_;
413 
414  if (last_run_time_ == 0.0) {
415  total_loop_time = 0.0;
416  total_loop_cpu = 0.0;
417  }
418 
419  double sum_all_events_time = 0;
420  for (auto t : sum_events_time_) {
421  sum_all_events_time += t;
422  }
423 
424  double average_event_time = 0.0;
425  if (total_event_count_ != 0) {
426  average_event_time = sum_all_events_time / total_event_count_;
427  }
428 
429  double event_throughput = 0.0;
430  if (total_loop_time != 0.0) {
431  event_throughput = total_event_count_ / total_loop_time;
432  }
433 
434  LogImportant("TimeReport") << "TimeReport> Time report complete in " << total_job_time << " seconds"
435  << "\n"
436  << " Time Summary: \n"
437  << " - Min event: " << min_event_time << "\n"
438  << " - Max event: " << max_event_time << "\n"
439  << " - Avg event: " << average_event_time << "\n"
440  << " - Total loop: " << total_loop_time << "\n"
441  << " - Total init: " << total_initialization_time << "\n"
442  << " - Total job: " << total_job_time << "\n"
443  << " - EventSetup Lock: " << accumulatedTimeForLock_ << "\n"
444  << " - EventSetup Get: " << accumulatedTimeForGet_ << "\n"
445  << " Event Throughput: " << event_throughput << " ev/s\n"
446  << " CPU Summary: \n"
447  << " - Total loop: " << total_loop_cpu << "\n"
448  << " - Total init: " << total_initialization_cpu << "\n"
449  << " - Total extra: " << extra_job_cpu_ << "\n"
450  << " - Total job: " << total_job_cpu << "\n"
451  << " Processing Summary: \n"
452  << " - Number of Events: " << total_event_count_ << "\n"
453  << " - Number of Global Begin Lumi Calls: " << begin_lumi_count_ << "\n"
454  << " - Number of Global Begin Run Calls: " << begin_run_count_ << "\n";
455 
456  if (report_summary_) {
457  Service<JobReport> reportSvc;
458  std::map<std::string, std::string> reportData;
459 
460  reportData.insert(std::make_pair("MinEventTime", d2str(min_event_time)));
461  reportData.insert(std::make_pair("MaxEventTime", d2str(max_event_time)));
462  reportData.insert(std::make_pair("AvgEventTime", d2str(average_event_time)));
463  reportData.insert(std::make_pair("EventThroughput", d2str(event_throughput)));
464  reportData.insert(std::make_pair("TotalJobTime", d2str(total_job_time)));
465  reportData.insert(std::make_pair("TotalJobCPU", d2str(total_job_cpu)));
466  reportData.insert(std::make_pair("TotalLoopTime", d2str(total_loop_time)));
467  reportData.insert(std::make_pair("TotalLoopCPU", d2str(total_loop_cpu)));
468  reportData.insert(std::make_pair("TotalInitTime", d2str(total_initialization_time)));
469  reportData.insert(std::make_pair("TotalInitCPU", d2str(total_initialization_cpu)));
470  reportData.insert(std::make_pair("NumberOfStreams", ui2str(nStreams_)));
471  reportData.insert(std::make_pair("NumberOfThreads", ui2str(nThreads_)));
472  reportData.insert(std::make_pair("EventSetup Lock", d2str(accumulatedTimeForLock_)));
473  reportData.insert(std::make_pair("EventSetup Get", d2str(accumulatedTimeForGet_)));
474  reportSvc->reportPerformanceSummary("Timing", reportData);
475 
476  std::map<std::string, std::string> reportData1;
477  reportData1.insert(std::make_pair("NumberEvents", ui2str(total_event_count_)));
478  reportData1.insert(std::make_pair("NumberBeginLumiCalls", ui2str(begin_lumi_count_)));
479  reportData1.insert(std::make_pair("NumberBeginRunCalls", ui2str(begin_run_count_)));
480  reportSvc->reportPerformanceSummary("ProcessingSummary", reportData1);
481  }
482  }
std::vector< double > sum_events_time_
Definition: Timing.cc:130
double curr_job_time_
Definition: Timing.cc:115
std::atomic< double > last_run_cpu_
Definition: Timing.cc:120
std::vector< double > max_events_time_
Definition: Timing.cc:128
static double getCPU()
Definition: Timing.cc:176
double curr_job_cpu_
Definition: Timing.cc:116
std::atomic< unsigned long > begin_lumi_count_
Definition: Timing.cc:132
unsigned int nThreads_
Definition: Timing.cc:135
unsigned int nStreams_
Definition: Timing.cc:134
std::atomic< double > last_run_time_
Definition: Timing.cc:119
double accumulatedTimeForLock_
Definition: Timing.cc:140
static double jobStartTime()
static std::string ui2str(unsigned int i)
Definition: Timing.cc:163
std::atomic< unsigned long > begin_run_count_
Definition: Timing.cc:133
std::atomic< unsigned long > total_event_count_
Definition: Timing.cc:131
static std::string d2str(double d)
bool configuredInTopLevelProcess_
Definition: Timing.cc:148
double accumulatedTimeForGet_
Definition: Timing.cc:143
static double getTime()
Definition: Timing.cc:169
std::atomic< double > extra_job_cpu_
Definition: Timing.cc:117
std::vector< double > min_events_time_
Definition: Timing.cc:129
void edm::service::Timing::postEvent ( StreamContext const &  iStream)
private

Definition at line 501 of file Timing.cc.

References KineDebug3::count(), edm::service::getTime(), lastPostEvent(), edm::StreamContext::streamID(), and edm::StreamID::value().

501  {
503  return;
504  }
505  auto index = iStream.streamID().value();
506  if (nSubProcesses_ == 0u) {
507  lastPostEvent(getTime() - curr_events_time_[index], index, iStream);
508  } else {
509  unsigned int count = ++(*countSubProcessesPostEvent_[index]);
510  if (count == (nSubProcesses_ + 1)) {
511  lastPostEvent(getTime() - curr_events_time_[index], index, iStream);
513  }
514  }
515  }
std::vector< double > curr_events_time_
Definition: Timing.cc:121
void lastPostEvent(double curr_event_time, unsigned int index, StreamContext const &iStream)
Definition: Timing.cc:517
std::vector< std::unique_ptr< std::atomic< unsigned int > > > countSubProcessesPostEvent_
Definition: Timing.cc:146
bool configuredInTopLevelProcess_
Definition: Timing.cc:148
static double getTime()
Definition: Timing.cc:169
unsigned int nSubProcesses_
Definition: Timing.cc:149
void edm::service::Timing::postEventSetupGet ( eventsetup::ComponentDescription const *  ,
eventsetup::EventSetupRecordKey const &  ,
eventsetup::DataKey const &   
)
private

Definition at line 627 of file Timing.cc.

References accumulateTimeEnd().

629  {
631  }
std::atomic< CountAndTime * > countAndTimeForGet_
Definition: Timing.cc:142
void accumulateTimeEnd(std::atomic< CountAndTime * > &countAndTime, double &accumulatedTime)
Definition: Timing.cc:656
double accumulatedTimeForGet_
Definition: Timing.cc:143
void edm::service::Timing::postGlobalBeginLumi ( GlobalContext const &  gc)
private

Definition at line 579 of file Timing.cc.

References begin_lumi_count_, edm::ProcessContext::isSubProcess(), and edm::GlobalContext::processContext().

579  {
581  return;
582  }
583  if (!gc.processContext()->isSubProcess()) {
585  }
586  }
std::atomic< unsigned long > begin_lumi_count_
Definition: Timing.cc:132
bool configuredInTopLevelProcess_
Definition: Timing.cc:148
void edm::service::Timing::postGlobalBeginRun ( GlobalContext const &  gc)
private

Definition at line 570 of file Timing.cc.

References begin_run_count_, edm::ProcessContext::isSubProcess(), and edm::GlobalContext::processContext().

570  {
572  return;
573  }
574  if (!gc.processContext()->isSubProcess()) {
576  }
577  }
std::atomic< unsigned long > begin_run_count_
Definition: Timing.cc:133
bool configuredInTopLevelProcess_
Definition: Timing.cc:148
void edm::service::Timing::postLockEventSetupGet ( eventsetup::ComponentDescription const *  ,
eventsetup::EventSetupRecordKey const &  ,
eventsetup::DataKey const &   
)
private

Definition at line 617 of file Timing.cc.

References accumulateTimeBegin(), and accumulateTimeEnd().

619  {
621  return;
622  }
625  }
void accumulateTimeBegin(std::atomic< CountAndTime * > &countAndTime, double &accumulatedTime)
Definition: Timing.cc:633
std::atomic< CountAndTime * > countAndTimeForGet_
Definition: Timing.cc:142
void accumulateTimeEnd(std::atomic< CountAndTime * > &countAndTime, double &accumulatedTime)
Definition: Timing.cc:656
std::atomic< CountAndTime * > countAndTimeForLock_
Definition: Timing.cc:139
double accumulatedTimeForLock_
Definition: Timing.cc:140
bool configuredInTopLevelProcess_
Definition: Timing.cc:148
double accumulatedTimeForGet_
Definition: Timing.cc:143
void edm::service::Timing::postModule ( ModuleDescription const &  md)
private

Definition at line 562 of file Timing.cc.

References postCommon().

562 { postCommon(); }
double postCommon() const
Definition: Timing.cc:594
void edm::service::Timing::postModuleEvent ( StreamContext const &  iStream,
ModuleCallingContext const &  iModule 
)
private

Definition at line 531 of file Timing.cc.

References edm::StreamContext::eventID(), edm::ModuleCallingContext::moduleDescription(), postCommon(), and lumiQTWidget::t.

531  {
533  return;
534  }
535  auto const& eventID = iStream.eventID();
536  auto const& desc = *(iModule.moduleDescription());
537  double t = postCommon();
538  if (not summary_only_) {
539  LogPrint("TimeModule") << "TimeModule> " << eventID.event() << " " << eventID.run() << " " << desc.moduleLabel()
540  << " " << desc.moduleName() << " " << t;
541  }
542  }
double postCommon() const
Definition: Timing.cc:594
bool configuredInTopLevelProcess_
Definition: Timing.cc:148
void edm::service::Timing::postModuleGlobal ( GlobalContext const &  ,
ModuleCallingContext const &  mcc 
)
private

Definition at line 568 of file Timing.cc.

References postCommon().

568 { postCommon(); }
double postCommon() const
Definition: Timing.cc:594
void edm::service::Timing::postModuleStream ( StreamContext const &  ,
ModuleCallingContext const &  mcc 
)
private

Definition at line 592 of file Timing.cc.

References postCommon().

592 { postCommon(); }
double postCommon() const
Definition: Timing.cc:594
void edm::service::Timing::postOpenFile ( std::string const &  lfn,
bool  b 
)
private

Definition at line 558 of file Timing.cc.

References postCommon().

558 { postCommon(); }
double postCommon() const
Definition: Timing.cc:594
void edm::service::Timing::postSourceEvent ( StreamID  sid)
private

Definition at line 546 of file Timing.cc.

References postCommon().

546 { postCommon(); }
double postCommon() const
Definition: Timing.cc:594
void edm::service::Timing::postSourceLumi ( LuminosityBlockIndex  index)
private

Definition at line 550 of file Timing.cc.

References postCommon().

550 { postCommon(); }
double postCommon() const
Definition: Timing.cc:594
void edm::service::Timing::postSourceRun ( RunIndex  index)
private

Definition at line 554 of file Timing.cc.

References postCommon().

554 { postCommon(); }
double postCommon() const
Definition: Timing.cc:594
void edm::service::Timing::preBeginJob ( PathsAndConsumesOfModulesBase const &  pathsAndConsumes,
ProcessContext const &  pc 
)
private

Definition at line 357 of file Timing.cc.

References edm::ProcessContext::isSubProcess(), and nSubProcesses_.

357  {
358  if (pc.isSubProcess()) {
359  ++nSubProcesses_;
360  } else {
362  }
363  }
bool configuredInTopLevelProcess_
Definition: Timing.cc:148
unsigned int nSubProcesses_
Definition: Timing.cc:149
void edm::service::Timing::preEvent ( StreamContext const &  iStream)
private

Definition at line 484 of file Timing.cc.

References KineDebug3::count(), edm::service::getTime(), edm::StreamContext::streamID(), and edm::StreamID::value().

484  {
486  return;
487  }
488  auto index = iStream.streamID().value();
489  if (nSubProcesses_ == 0u) {
491  } else {
492  unsigned int count = ++(*countSubProcessesPreEvent_[index]);
493  if (count == 1) {
495  } else if (count == (nSubProcesses_ + 1)) {
497  }
498  }
499  }
std::vector< double > curr_events_time_
Definition: Timing.cc:121
std::vector< std::unique_ptr< std::atomic< unsigned int > > > countSubProcessesPreEvent_
Definition: Timing.cc:145
bool configuredInTopLevelProcess_
Definition: Timing.cc:148
static double getTime()
Definition: Timing.cc:169
unsigned int nSubProcesses_
Definition: Timing.cc:149
void edm::service::Timing::preLockEventSetupGet ( eventsetup::ComponentDescription const *  ,
eventsetup::EventSetupRecordKey const &  ,
eventsetup::DataKey const &   
)
private

Definition at line 608 of file Timing.cc.

References accumulateTimeBegin().

610  {
612  return;
613  }
615  }
void accumulateTimeBegin(std::atomic< CountAndTime * > &countAndTime, double &accumulatedTime)
Definition: Timing.cc:633
std::atomic< CountAndTime * > countAndTimeForLock_
Definition: Timing.cc:139
double accumulatedTimeForLock_
Definition: Timing.cc:140
bool configuredInTopLevelProcess_
Definition: Timing.cc:148
void edm::service::Timing::preModule ( ModuleDescription const &  md)
private

Definition at line 560 of file Timing.cc.

References edm::service::pushStack().

static void pushStack(bool configuredInTopLevelProcess)
Definition: Timing.cc:211
bool configuredInTopLevelProcess_
Definition: Timing.cc:148
void edm::service::Timing::preModuleGlobal ( GlobalContext const &  ,
ModuleCallingContext const &   
)
private

Definition at line 564 of file Timing.cc.

References edm::service::pushStack().

564  {
566  }
static void pushStack(bool configuredInTopLevelProcess)
Definition: Timing.cc:211
bool configuredInTopLevelProcess_
Definition: Timing.cc:148
void edm::service::Timing::preModuleStream ( StreamContext const &  ,
ModuleCallingContext const &   
)
private

Definition at line 588 of file Timing.cc.

References edm::service::pushStack().

588  {
590  }
static void pushStack(bool configuredInTopLevelProcess)
Definition: Timing.cc:211
bool configuredInTopLevelProcess_
Definition: Timing.cc:148
void edm::service::Timing::preOpenFile ( std::string const &  lfn,
bool  b 
)
private

Definition at line 556 of file Timing.cc.

References edm::service::pushStack().

static void pushStack(bool configuredInTopLevelProcess)
Definition: Timing.cc:211
bool configuredInTopLevelProcess_
Definition: Timing.cc:148
void edm::service::Timing::preSourceEvent ( StreamID  sid)
private

Definition at line 544 of file Timing.cc.

References edm::service::pushStack().

static void pushStack(bool configuredInTopLevelProcess)
Definition: Timing.cc:211
bool configuredInTopLevelProcess_
Definition: Timing.cc:148
void edm::service::Timing::preSourceLumi ( LuminosityBlockIndex  index)
private

Definition at line 548 of file Timing.cc.

References edm::service::pushStack().

static void pushStack(bool configuredInTopLevelProcess)
Definition: Timing.cc:211
bool configuredInTopLevelProcess_
Definition: Timing.cc:148
void edm::service::Timing::preSourceRun ( RunIndex  index)
private

Definition at line 552 of file Timing.cc.

References edm::service::pushStack().

static void pushStack(bool configuredInTopLevelProcess)
Definition: Timing.cc:211
bool configuredInTopLevelProcess_
Definition: Timing.cc:148

Member Data Documentation

double edm::service::Timing::accumulatedTimeForGet_
private

Definition at line 143 of file Timing.cc.

double edm::service::Timing::accumulatedTimeForLock_
private

Definition at line 140 of file Timing.cc.

std::atomic<unsigned long> edm::service::Timing::begin_lumi_count_
private

Definition at line 132 of file Timing.cc.

Referenced by postGlobalBeginLumi().

std::atomic<unsigned long> edm::service::Timing::begin_run_count_
private

Definition at line 133 of file Timing.cc.

Referenced by postGlobalBeginRun().

bool edm::service::Timing::configuredInTopLevelProcess_
private

Definition at line 148 of file Timing.cc.

std::atomic<CountAndTime*> edm::service::Timing::countAndTimeForGet_
private

Definition at line 142 of file Timing.cc.

std::atomic<CountAndTime*> edm::service::Timing::countAndTimeForLock_
private

Definition at line 139 of file Timing.cc.

CountAndTime edm::service::Timing::countAndTimeZero_
private

Definition at line 137 of file Timing.cc.

std::vector<std::unique_ptr<std::atomic<unsigned int> > > edm::service::Timing::countSubProcessesPostEvent_
private

Definition at line 146 of file Timing.cc.

std::vector<std::unique_ptr<std::atomic<unsigned int> > > edm::service::Timing::countSubProcessesPreEvent_
private

Definition at line 145 of file Timing.cc.

std::vector<double> edm::service::Timing::curr_events_time_
private

Definition at line 121 of file Timing.cc.

double edm::service::Timing::curr_job_cpu_
private

Definition at line 116 of file Timing.cc.

Referenced by postEndJob().

double edm::service::Timing::curr_job_time_
private

Definition at line 115 of file Timing.cc.

Referenced by postEndJob().

std::atomic<double> edm::service::Timing::extra_job_cpu_
private

Definition at line 117 of file Timing.cc.

Referenced by postEndJob().

std::atomic<double> edm::service::Timing::last_run_cpu_
private

Definition at line 120 of file Timing.cc.

std::atomic<double> edm::service::Timing::last_run_time_
private

Definition at line 119 of file Timing.cc.

std::vector<double> edm::service::Timing::max_events_time_
private

Definition at line 128 of file Timing.cc.

std::vector<double> edm::service::Timing::min_events_time_
private

Definition at line 129 of file Timing.cc.

unsigned int edm::service::Timing::nStreams_
private

Definition at line 134 of file Timing.cc.

unsigned int edm::service::Timing::nSubProcesses_
private

Definition at line 149 of file Timing.cc.

Referenced by preBeginJob().

unsigned int edm::service::Timing::nThreads_
private

Definition at line 135 of file Timing.cc.

bool edm::service::Timing::report_summary_
private

Definition at line 123 of file Timing.cc.

std::vector<double> edm::service::Timing::sum_events_time_
private

Definition at line 130 of file Timing.cc.

bool edm::service::Timing::summary_only_
private

Definition at line 122 of file Timing.cc.

double edm::service::Timing::threshold_
private

Definition at line 124 of file Timing.cc.

std::atomic<unsigned long> edm::service::Timing::total_event_count_
private

Definition at line 131 of file Timing.cc.

Referenced by lastPostEvent(), and postEndJob().