CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FastMonitoringService.cc
Go to the documentation of this file.
2 #include <iostream>
3 
5 #include <iomanip>
6 #include <sys/time.h>
7 
18 
21 using namespace jsoncollector;
22 
25 
26 constexpr double throughputFactor() {return (1000000)/double(1024*1024);}
27 
28 static const int nReservedModules = 64;
29 static const int nSpecialModules = 7;
30 static const int nReservedPaths = 1;
31 
32 namespace evf{
33 
34  const std::string FastMonitoringService::macroStateNames[FastMonitoringThread::MCOUNT] =
35  {"Init","JobReady","RunGiven","Running",
36  "Stopping","Done","JobEnded","Error","ErrorEnded","End",
37  "Invalid"};
38 
39  const std::string FastMonitoringService::nopath_ = "NoPath";
40 
41  FastMonitoringService::FastMonitoringService(const edm::ParameterSet& iPS,
42  edm::ActivityRegistry& reg) :
43  MicroStateService(iPS,reg)
44  ,encModule_(nReservedModules)
45  ,nStreams_(0)//until initialized
46  ,sleepTime_(iPS.getUntrackedParameter<int>("sleepTime", 1))
47  ,fastMonIntervals_(iPS.getUntrackedParameter<unsigned int>("fastMonIntervals", 2))
48  ,fastName_("fastmoni")
49  ,slowName_("slowmoni")
50  ,totalEventsProcessed_(0)
51  {
52  reg.watchPreallocate(this, &FastMonitoringService::preallocate);//receiving information on number of threads
54 
58 
62 
67 
69 
72 
73  reg.watchPreSourceEvent(this,&FastMonitoringService::preSourceEvent);//source (with streamID of requestor)
75 
78 
82 
83  //find microstate definition path (required by the module)
84  struct stat statbuf;
85  std::string microstateBaseSuffix = "src/EventFilter/Utilities/plugins/microstatedef.jsd";
86  std::string microstatePath = std::string(getenv("CMSSW_BASE")) + "/" + microstateBaseSuffix;
87  if (stat(microstatePath.c_str(), &statbuf)) {
88  microstatePath = std::string(getenv("CMSSW_RELEASE_BASE")) + "/" + microstateBaseSuffix;
89  if (stat(microstatePath.c_str(), &statbuf)) {
90  microstatePath = microstateBaseSuffix;
91  if (stat(microstatePath.c_str(), &statbuf))
92  throw cms::Exception("FastMonitoringService") << "microstate definition file not found";
93  }
94  }
95  fastMicrostateDefPath_ = microstateDefPath_ = microstatePath;
96  }
97 
98 
100  {
101  }
102 
104  {
106  desc.setComment("Service for File-based DAQ monitoring and event accounting");
107  desc.addUntracked<int> ("sleepTime",1)->setComment("Sleep time of the monitoring thread");
108  desc.addUntracked<unsigned int> ("fastMonIntervals",2)->setComment("Modulo of sleepTime intervals on which fastmon file is written out");
109  desc.setAllowAnything();
110  descriptions.add("FastMonitoringService", desc);
111  }
112 
113 
115  Json::Value legendaVector(Json::arrayValue);
116  for(int i = 0; i < encPath_[0].current_; i++)
117  legendaVector.append(Json::Value(*(static_cast<const std::string *>(encPath_[0].decode(i)))));
118  Json::Value valReserved(nReservedPaths);
119  Json::Value pathLegend;
120  pathLegend["names"]=legendaVector;
121  pathLegend["reserved"]=valReserved;
122  Json::StyledWriter writer;
123  return writer.write(pathLegend);
124  }
125 
127  Json::Value legendaVector(Json::arrayValue);
128  for(int i = 0; i < encModule_.current_; i++)
129  legendaVector.append(Json::Value((static_cast<const edm::ModuleDescription *>(encModule_.decode(i)))->moduleLabel()));
130  Json::Value valReserved(nReservedModules);
131  Json::Value valSpecial(nSpecialModules);
132  Json::Value valOutputModules(nOutputModules_);
133  Json::Value moduleLegend;
134  moduleLegend["names"]=legendaVector;
135  moduleLegend["reserved"]=valReserved;
136  moduleLegend["special"]=valSpecial;
137  moduleLegend["output"]=valOutputModules;
138  Json::StyledWriter writer;
139  return writer.write(moduleLegend);
140  }
141 
143  {
144 
145  // FIND RUN DIRECTORY
146  // The run dir should be set via the configuration of EvFDaqDirector
147 
148  if (edm::Service<evf::EvFDaqDirector>().operator->()==nullptr)
149  {
150  throw cms::Exception("FastMonitoringService") << "EvFDaqDirector is not present";
151 
152  }
153  emptyLumisectionMode_ = edm::Service<evf::EvFDaqDirector>()->emptyLumisectionMode();
154  boost::filesystem::path runDirectory(edm::Service<evf::EvFDaqDirector>()->baseRunDir());
155  workingDirectory_ = runDirectory_ = runDirectory;
156  workingDirectory_ /= "mon";
157 
158  if ( !boost::filesystem::is_directory(workingDirectory_)) {
159  LogDebug("FastMonitoringService") << "<MON> DIR NOT FOUND! Trying to create -: " << workingDirectory_.string() ;
160  boost::filesystem::create_directories(workingDirectory_);
161  if ( !boost::filesystem::is_directory(workingDirectory_))
162  edm::LogWarning("FastMonitoringService") << "Unable to create <MON> DIR -: " << workingDirectory_.string()
163  << ". No monitoring data will be written.";
164  }
165 
166  std::ostringstream fastFileName;
167 
168  fastFileName << fastName_ << "_pid" << std::setfill('0') << std::setw(5) << getpid() << ".fast";
170  fast /= fastFileName.str();
171  fastPath_ = fast.string();
172 
173  std::ostringstream moduleLegFile;
174  std::ostringstream moduleLegFileJson;
175  moduleLegFile << "microstatelegend_pid" << std::setfill('0') << std::setw(5) << getpid() << ".leg";
176  moduleLegFileJson << "microstatelegend_pid" << std::setfill('0') << std::setw(5) << getpid() << ".jsn";
177  moduleLegendFile_ = (workingDirectory_/moduleLegFile.str()).string();
178  moduleLegendFileJson_ = (workingDirectory_/moduleLegFileJson.str()).string();
179 
180  std::ostringstream pathLegFile;
181  std::ostringstream pathLegFileJson;
182  pathLegFile << "pathlegend_pid" << std::setfill('0') << std::setw(5) << getpid() << ".leg";
183  pathLegendFile_ = (workingDirectory_/pathLegFile.str()).string();
184  pathLegFileJson << "pathlegend_pid" << std::setfill('0') << std::setw(5) << getpid() << ".jsn";
185  pathLegendFileJson_ = (workingDirectory_/pathLegFileJson.str()).string();
186 
187  LogDebug("FastMonitoringService") << "Initializing FastMonitor with microstate def path -: "
189  //<< encPath_.current_ + 1 << " " << encModule_.current_ + 1
190 
191  nStreams_=bounds.maxNumberOfStreams();
192  nThreads_=bounds.maxNumberOfThreads();
193 
194  //this should already be >=1
195  if (nStreams_==0) nStreams_=1;
196  if (nThreads_==0) nThreads_=1;
197 
198  /*
199  * initialize the fast monitor with:
200  * vector of pointers to monitorable parameters
201  * path to definition
202  *
203  */
204 
206 
207  for(unsigned int i = 0; i < (mCOUNT); i++)
208  encModule_.updateReserved(static_cast<const void*>(reservedMicroStateNames+i));
210 
211  for (unsigned int i=0;i<nStreams_;i++) {
212  ministate_.push_back(&nopath_);
214 
215  //for synchronization
216  streamCounterUpdating_.push_back(new std::atomic<bool>(0));
217 
218  //path (mini) state
219  encPath_.emplace_back(0);
220  encPath_[i].update(static_cast<const void*>(&nopath_));
221  eventCountForPathInit_.push_back(0);
222  firstEventId_.push_back(0);
223  collectedPathList_.push_back(new std::atomic<bool>(0));
224 
225  }
226  //for (unsigned int i=0;i<nThreads_;i++)
227  // threadMicrostate_.push_back(&reservedMicroStateNames[mInvalid]);
228 
229  //initial size until we detect number of bins
233 
234  lastGlobalLumi_=0;
236  lumiFromSource_=0;
237 
238  //startup monitoring
240  fmt_.jsonMonitor_->setNStreams(nStreams_);
242  monInit_.store(false,std::memory_order_release);
244 
245  //this definition needs: #include "tbb/compat/thread"
246  //however this would results in TBB imeplementation replacing std::thread
247  //(both supposedly call pthread_self())
248  //number of threads created in process could be obtained from /proc,
249  //assuming that all posix threads are true kernel threads capable of running in parallel
250 
251  //#if TBB_IMPLEMENT_CPP0X
253  //threadIDAvailable_=true;
254  //#endif
255 
256  }
257 
259  {
260  std::string context;
261  if (to==edm::TerminationOrigin::ExceptionFromThisContext) context = " FromThisContext ";
262  if (to==edm::TerminationOrigin::ExceptionFromAnotherContext) context = " FromAnotherContext";
263  if (to==edm::TerminationOrigin::ExternalSignal) context = " FromExternalSignal";
264  edm::LogWarning("FastMonitoringService") << " STREAM " << sc.streamID().value() << " earlyTermination -: ID:"<< sc.eventID()
265  << " LS:" << sc.eventID().luminosityBlock() << " " << context;
266  std::lock_guard<std::mutex> lock(fmt_.monlock_);
267  exceptionInLS_.push_back(sc.eventID().luminosityBlock());
268  }
269 
271  {
272  std::string context;
273  if (to==edm::TerminationOrigin::ExceptionFromThisContext) context = " FromThisContext ";
274  if (to==edm::TerminationOrigin::ExceptionFromAnotherContext) context = " FromAnotherContext";
275  if (to==edm::TerminationOrigin::ExternalSignal) context = " FromExternalSignal";
276  edm::LogWarning("FastMonitoringService") << " GLOBAL " << "earlyTermination -: LS:"
277  << gc.luminosityBlockID().luminosityBlock() << " " << context;
278  std::lock_guard<std::mutex> lock(fmt_.monlock_);
280  }
281 
283  {
284  std::string context;
285  if (to==edm::TerminationOrigin::ExceptionFromThisContext) context = " FromThisContext ";
286  if (to==edm::TerminationOrigin::ExceptionFromAnotherContext) context = " FromAnotherContext";
287  if (to==edm::TerminationOrigin::ExternalSignal) context = " FromExternalSignal";
288  edm::LogWarning("FastMonitoringService") << " SOURCE " << "earlyTermination -: " << context;
289  std::lock_guard<std::mutex> lock(fmt_.monlock_);
290  exception_detected_=true;
291  }
292 
294  if (!ls) exception_detected_=true;
295  else exceptionInLS_.push_back(ls);
296  }
297 
299  {
301  }
302 
303  //new output module name is stream
305  {
306  std::lock_guard<std::mutex> lock(fmt_.monlock_);
307  //std::cout << " Pre module Begin Job module: " << desc.moduleName() << std::endl;
308 
309  //build a map of modules keyed by their module description address
310  //here we need to treat output modules in a special way so they can be easily singled out
311  if(desc.moduleName() == "Stream" || desc.moduleName() == "ShmStreamConsumer" || desc.moduleName() == "EvFOutputModule" ||
312  desc.moduleName() == "EventStreamFileWriter" || desc.moduleName() == "PoolOutputModule") {
313  encModule_.updateReserved((void*)&desc);
314  nOutputModules_++;
315  }
316  else
317  encModule_.update((void*)&desc);
318  }
319 
321  {
322  std::string && moduleLegStrJson = makeModuleLegendaJson();
323  FileIO::writeStringToFile(moduleLegendFileJson_, moduleLegStrJson);
324 
326 
327  //update number of entries in module histogram
328  std::lock_guard<std::mutex> lock(fmt_.monlock_);
330  }
331 
333  {
335  fmt_.stop();
336  }
337 
339  {
341  }
342 
344  {
345 
346  timeval lumiStartTime;
347  gettimeofday(&lumiStartTime, 0);
348  unsigned int newLumi = gc.luminosityBlockID().luminosityBlock();
349 
350  std::lock_guard<std::mutex> lock(fmt_.monlock_);
351 
352  lumiStartTime_[newLumi]=lumiStartTime;
353  while (!lastGlobalLumisClosed_.empty()) {
354  //wipe out old map entries as they aren't needed and slow down access
355  unsigned int oldLumi = lastGlobalLumisClosed_.back();
357  lumiStartTime_.erase(oldLumi);
358  avgLeadTime_.erase(oldLumi);
359  filesProcessedDuringLumi_.erase(oldLumi);
360  accuSize_.erase(oldLumi);
361  lockStatsDuringLumi_.erase(oldLumi);
362  processedEventsPerLumi_.erase(oldLumi);
363  }
364  lastGlobalLumi_= newLumi;
366  }
367 
369  {
370  unsigned int lumi = gc.luminosityBlockID().luminosityBlock();
371  LogDebug("FastMonitoringService") << "Lumi ended. Writing JSON information. LUMI -: "
372  << lumi;
373  timeval lumiStopTime;
374  gettimeofday(&lumiStopTime, 0);
375 
376  std::lock_guard<std::mutex> lock(fmt_.monlock_);
377 
378  // Compute throughput
379  timeval stt = lumiStartTime_[lumi];
380  unsigned long usecondsForLumi = (lumiStopTime.tv_sec - stt.tv_sec)*1000000
381  + (lumiStopTime.tv_usec - stt.tv_usec);
382  unsigned long accuSize = accuSize_.find(lumi)==accuSize_.end() ? 0 : accuSize_[lumi];
383  double throughput = throughputFactor()* double(accuSize) / double(usecondsForLumi);
384  //store to registered variable
385  fmt_.m_data.fastThroughputJ_.value() = throughput;
386 
387  //update
388  doSnapshot(lumi,true);
389 
390  // create file name for slow monitoring file
391  std::stringstream slowFileName;
392  slowFileName << slowName_ << "_ls" << std::setfill('0') << std::setw(4)
393  << lumi << "_pid" << std::setfill('0')
394  << std::setw(5) << getpid() << ".jsn";
396  slow /= slowFileName.str();
397 
398  //retrieve one result we need (todo: sanity check if it's found)
399  IntJ *lumiProcessedJptr = dynamic_cast<IntJ*>(fmt_.jsonMonitor_->getMergedIntJForLumi("Processed",lumi));
400  if (!lumiProcessedJptr)
401  throw cms::Exception("FastMonitoringService") << "Internal error: got null pointer from FastMonitor";
402  processedEventsPerLumi_[lumi] = std::pair<unsigned int,bool>(lumiProcessedJptr->value(),false);
403 
404  //checking if exception has been thrown (in case of Global/Stream early termination, for this LS)
405  bool exception_detected = exception_detected_;
406  for (auto ex : exceptionInLS_)
407  if (lumi == ex) exception_detected=true;
408 
409  if (edm::shutdown_flag || exception_detected) {
410  edm::LogInfo("FastMonitoringService") << "Run interrupted. Skip writing EoL information -: "
411  << processedEventsPerLumi_[lumi].first << " events were processed in LUMI " << lumi;
412  //this will prevent output modules from producing json file for possibly incomplete lumi
413  processedEventsPerLumi_[lumi].first=0;
414  processedEventsPerLumi_[lumi].second=true;
415  //disable this exception, so service can be used standalone (will be thrown if output module asks for this information)
416  //throw cms::Exception("FastMonitoringService") << "SOURCE did not send update for lumi block. LUMI -:" << lumi;
417  return;
418 
419  }
420 
421  if (inputSource_) {
422  auto sourceReport = inputSource_->getEventReport(lumi, true);
423  if (sourceReport.first) {
424  if (sourceReport.second!=processedEventsPerLumi_[lumi].first) {
425  throw cms::Exception("FastMonitoringService") << "MISMATCH with SOURCE update. LUMI -: "
426  << lumi
427  << ", events(processed):" << processedEventsPerLumi_[lumi].first
428  << " events(source):" << sourceReport.second;
429  }
430  }
431  }
432  edm::LogInfo("FastMonitoringService") << "Statistics for lumisection -: lumi = " << lumi << " events = "
433  << lumiProcessedJptr->value() << " time = " << usecondsForLumi/1000000
434  << " size = " << accuSize << " thr = " << throughput;
435  delete lumiProcessedJptr;
436 
437  //full global and stream merge&output for this lumi
438  fmt_.jsonMonitor_->outputFullJSON(slow.string(),lumi);//full global and stream merge and JSON write for this lumi
439  fmt_.jsonMonitor_->discardCollected(lumi);//we don't do further updates for this lumi
440 
442  }
443 
445  {
446  //mark closed lumis (still keep map entries until next one)
448  }
449 
451  {
452  unsigned int sid = sc.streamID().value();
453  std::lock_guard<std::mutex> lock(fmt_.monlock_);
455 
456  //reset collected values for this stream
457  *(fmt_.m_data.processed_[sid])=0;
458 
459  ministate_[sid]=&nopath_;
461  }
462 
464  {
466  }
467 
469  {
470  unsigned int sid = sc.streamID().value();
471  std::lock_guard<std::mutex> lock(fmt_.monlock_);
472 
473  #if ATOMIC_LEVEL>=2
474  //spinlock to make sure we are not still updating event counter somewhere
475  while (streamCounterUpdating_[sid]->load(std::memory_order_acquire)) {}
476  #endif
477 
478  //update processed count to be complete at this time
480  //reset this in case stream does not get notified of next lumi (we keep processed events only)
481  ministate_[sid]=&nopath_;
483  }
485  {
487  }
488 
489 
491  {
492  //make sure that all path names are retrieved before allowing ministate to change
493  //hack: assume memory is synchronized after ~50 events seen by each stream
494  if (unlikely(eventCountForPathInit_[sc.streamID()]<50) && false==collectedPathList_[sc.streamID()]->load(std::memory_order_acquire))
495  {
496  //protection between stream threads, as well as the service monitoring thread
497  std::lock_guard<std::mutex> lock(fmt_.monlock_);
498 
499  if (firstEventId_[sc.streamID()]==0)
500  firstEventId_[sc.streamID()]=sc.eventID().event();
501  if (sc.eventID().event()==firstEventId_[sc.streamID()])
502  {
503  encPath_[sc.streamID()].update((void*)&pc.pathName());
504  return;
505  }
506  else {
507  //finished collecting path names
508  collectedPathList_[sc.streamID()]->store(true,std::memory_order_seq_cst);
509  fmt_.m_data.ministateBins_=encPath_[sc.streamID()].vecsize();
510  if (!pathLegendWritten_) {
511  std::string pathLegendStrJson = makePathLegendaJson();
512  FileIO::writeStringToFile(pathLegendFileJson_, pathLegendStrJson);
513  pathLegendWritten_=true;
514  }
515  }
516  }
517  else {
518  ministate_[sc.streamID()] = &(pc.pathName());
519  }
520  }
521 
522 
524  {
525  }
526 
528  {
530 
531  ministate_[sc.streamID()] = &nopath_;
532 
533  #if ATOMIC_LEVEL>=2
534  //use atomic flag to make sure end of lumi sees this
535  streamCounterUpdating_[sc.streamID()]->store(true,std::memory_order_release);
536  fmt_.m_data.processed_[sc.streamID()]->fetch_add(1,std::memory_order_release);
537  streamCounterUpdating_[sc.streamID()]->store(false,std::memory_order_release);
538 
539  #elif ATOMIC_LEVEL==1
540  //writes are atomic, we assume writes propagate to memory before stream EOL snap
541  fmt_.m_data.processed_[sc.streamID()]->fetch_add(1,std::memory_order_relaxed);
542 
543  #elif ATOMIC_LEVEL==0 //default
544  (*(fmt_.m_data.processed_[sc.streamID()]))++;
545  #endif
547 
548  //fast path counter (events accumulated in a run)
549  unsigned long res = totalEventsProcessed_.fetch_add(1,std::memory_order_relaxed);
551  //fmt_.m_data.fastPathProcessedJ_ = totalEventsProcessed_.load(std::memory_order_relaxed);
552  }
553 
555  {
557  }
558 
560  {
562  }
563 
565  {
566  microstate_[sc.streamID().value()] = (void*)(mcc.moduleDescription());
567  }
568 
570  {
571  //microstate_[sc.streamID().value()] = (void*)(mcc.moduleDescription());
573  }
574 
575  //FUNCTIONS CALLED FROM OUTSIDE
576 
577  //this is for old-fashioned service that is not thread safe and can block other streams
578  //(we assume the worst case - everything is blocked)
580  {
581  for (unsigned int i=0;i<nStreams_;i++)
583  }
584 
585  //this is for services that are multithreading-enabled or rarely blocks other streams
587  {
589  }
590 
591  //from source
592  void FastMonitoringService::accumulateFileSize(unsigned int lumi, unsigned long fileSize) {
593  std::lock_guard<std::mutex> lock(fmt_.monlock_);
594 
595  if (accuSize_.find(lumi)==accuSize_.end()) accuSize_[lumi] = fileSize;
596  else accuSize_[lumi] += fileSize;
597 
599  filesProcessedDuringLumi_[lumi] = 1;
600  else
602  }
603 
605  gettimeofday(&fileLookStart_, 0);
606  /*
607  std::cout << "Started looking for .raw file at: s=" << fileLookStart_.tv_sec << ": ms = "
608  << fileLookStart_.tv_usec / 1000.0 << std::endl;
609  */
610  }
611 
613  gettimeofday(&fileLookStop_, 0);
614  /*
615  std::cout << "Stopped looking for .raw file at: s=" << fileLookStop_.tv_sec << ": ms = "
616  << fileLookStop_.tv_usec / 1000.0 << std::endl;
617  */
618  std::lock_guard<std::mutex> lock(fmt_.monlock_);
619 
620  if (lumi>lumiFromSource_) {
622  leadTimes_.clear();
623  }
624  unsigned long elapsedTime = (fileLookStop_.tv_sec - fileLookStart_.tv_sec) * 1000000 // sec to us
625  + (fileLookStop_.tv_usec - fileLookStart_.tv_usec); // us
626  // add this to lead times for this lumi
627  leadTimes_.push_back((double)elapsedTime);
628 
629  // recompute average lead time for this lumi
630  if (leadTimes_.size() == 1) avgLeadTime_[lumi] = leadTimes_[0];
631  else {
632  double totTime = 0;
633  for (unsigned int i = 0; i < leadTimes_.size(); i++) totTime += leadTimes_[i];
634  avgLeadTime_[lumi] = 0.001*(totTime / leadTimes_.size());
635  }
636  }
637 
638  void FastMonitoringService::reportLockWait(unsigned int ls, double waitTime, unsigned int lockCount)
639  {
640  std::lock_guard<std::mutex> lock(fmt_.monlock_);
641  lockStatsDuringLumi_[ls]=std::pair<double,unsigned int>(waitTime,lockCount);
642 
643  }
644 
645  //for the output module
646  unsigned int FastMonitoringService::getEventsProcessedForLumi(unsigned int lumi, bool * abortFlag) {
647  std::lock_guard<std::mutex> lock(fmt_.monlock_);
648 
649  auto it = processedEventsPerLumi_.find(lumi);
650  if (it!=processedEventsPerLumi_.end()) {
651  unsigned int proc = it->second.first;
652  if (abortFlag) *abortFlag=it->second.second;
653  return proc;
654  }
655  else {
656  throw cms::Exception("FastMonitoringService") << "output module wants already deleted (or never reported by SOURCE) lumisection event count for LUMI -: "<<lumi;
657  return 0;
658  }
659  }
660 
661  //for the output module
663  std::lock_guard<std::mutex> lock(fmt_.monlock_);
664 
665  auto it = processedEventsPerLumi_.find(lumi);
666  if (it!=processedEventsPerLumi_.end()) {
667  unsigned int abortFlag = it->second.second;
668  return abortFlag;
669  }
670  else {
671  throw cms::Exception("FastMonitoringService") << "output module wants already deleted (or never reported by SOURCE) lumisection status for LUMI -: "<<lumi;
672  return 0;
673  }
674  }
675 
676  void FastMonitoringService::doSnapshot(const unsigned int ls, const bool isGlobalEOL) {
677  // update macrostate
679 
680  //update these unless in the midst of a global transition
682 
683  auto itd = avgLeadTime_.find(ls);
684  if (itd != avgLeadTime_.end())
685  fmt_.m_data.fastAvgLeadTimeJ_ = itd->second;
686  else fmt_.m_data.fastAvgLeadTimeJ_=0.;
687 
688  auto iti = filesProcessedDuringLumi_.find(ls);
689  if (iti != filesProcessedDuringLumi_.end())
690  fmt_.m_data.fastFilesProcessedJ_ = iti->second;
692 
693  auto itrd = lockStatsDuringLumi_.find(ls);
694  if (itrd != lockStatsDuringLumi_.end()) {
695  fmt_.m_data.fastLockWaitJ_ = itrd->second.first;
696  fmt_.m_data.fastLockCountJ_ = itrd->second.second;
697  }
698  else {
701  }
702 
703  }
704  else return;
705 
706  //capture latest mini/microstate of streams
707  for (unsigned int i=0;i<nStreams_;i++) {
710  }
711  //for (unsigned int i=0;i<nThreads_;i++)
712  // fmt_.m_data.threadMicrostateEncoded_[i] = encModule_.encode(threadMicrostate_[i]);
713 
714  if (isGlobalEOL)
715  {//only update global variables
716  fmt_.jsonMonitor_->snapGlobal(ls);
717  }
718  else
719  fmt_.jsonMonitor_->snap(ls);
720  }
721 
722 } //end namespace evf
723 
#define LogDebug(id)
void prePathEvent(edm::StreamContext const &, edm::PathContext const &)
std::string const & pathName() const
Definition: PathContext.h:37
unsigned int maxNumberOfThreads() const
Definition: SystemBounds.h:46
EventNumber_t event() const
Definition: EventID.h:41
void watchPreStreamEarlyTermination(PreStreamEarlyTermination::slot_type const &iSlot)
void watchPreEvent(PreEvent::slot_type const &iSlot)
int i
Definition: DBlmapReader.cc:9
unsigned int getEventsProcessedForLumi(unsigned int lumi, bool *abortFlag=0)
static const edm::ModuleDescription reservedMicroStateNames[mCOUNT]
void watchPrePathEvent(PrePathEvent::slot_type const &iSlot)
void watchPreallocate(Preallocate::slot_type const &iSlot)
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void setExceptionDetected(unsigned int ls)
boost::filesystem::path runDirectory_
void watchPostEndJob(PostEndJob::slot_type const &iSlot)
void preallocate(edm::service::SystemBounds const &)
std::map< unsigned int, timeval > lumiStartTime_
void start(void(FastMonitoringService::*fp)(), FastMonitoringService *cp)
void preGlobalBeginLumi(edm::GlobalContext const &)
std::pair< bool, unsigned int > getEventReport(unsigned int lumi, bool erase)
void setAllowAnything()
allow any parameter label/value pairs
double throughputFactor()
void watchPreModuleEvent(PreModuleEvent::slot_type const &iSlot)
void postGlobalEndLumi(edm::GlobalContext const &)
TrainProcessor *const proc
Definition: MVATrainer.cc:101
void postEvent(edm::StreamContext const &)
void accumulateFileSize(unsigned int lumi, unsigned long fileSize)
void watchPreGlobalEndLumi(PreGlobalEndLumi::slot_type const &iSlot)
std::map< unsigned int, unsigned long > accuSize_
tuple lumi
Definition: fjr2json.py:35
std::vector< unsigned int > eventCountForPathInit_
std::vector< std::atomic< bool > * > streamCounterUpdating_
void watchPostEvent(PostEvent::slot_type const &iSlot)
static const int nReservedPaths
LuminosityBlockID const & luminosityBlockID() const
Definition: GlobalContext.h:52
def ls
Definition: eostools.py:348
void watchPostStreamEndLumi(PostStreamEndLumi::slot_type const &iSlot)
void watchPreGlobalBeginLumi(PreGlobalBeginLumi::slot_type const &iSlot)
std::string const & moduleName() const
void watchPostModuleEvent(PostModuleEvent::slot_type const &iSlot)
Value & append(const Value &value)
Append value to array at the end.
void watchPostSourceEvent(PostSourceEvent::slot_type const &iSlot)
volatile std::atomic< bool > shutdown_flag
void doStreamEOLSnapshot(const unsigned int ls, const unsigned int streamID)
std::map< unsigned int, unsigned int > filesProcessedDuringLumi_
void preGlobalEndLumi(edm::GlobalContext const &)
Represents a JSON value.
Definition: value.h:111
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:40
void watchPreStreamEndLumi(PreStreamEndLumi::slot_type const &iSlot)
void preGlobalEarlyTermination(edm::GlobalContext const &, edm::TerminationOrigin)
#define constexpr
void watchPreSourceEarlyTermination(PreSourceEarlyTermination::slot_type const &iSlot)
void watchJobFailure(JobFailure::slot_type const &iSlot)
convenience function for attaching to signal
void registerVariables(jsoncollector::FastMonitor *fm, unsigned int nStreams, unsigned int nThreads)
#define unlikely(x)
unsigned int maxNumberOfStreams() const
Definition: SystemBounds.h:43
void preModuleBeginJob(edm::ModuleDescription const &)
void setComment(std::string const &value)
std::vector< std::atomic< bool > * > collectedPathList_
std::queue< unsigned int > lastGlobalLumisClosed_
void preStreamEndLumi(edm::StreamContext const &)
std::map< unsigned int, double > avgLeadTime_
void watchPostStreamBeginLumi(PostStreamBeginLumi::slot_type const &iSlot)
void doSnapshot(const unsigned int ls, const bool isGlobalEOL)
void preStreamEarlyTermination(edm::StreamContext const &, edm::TerminationOrigin)
void watchPreGlobalEarlyTermination(PreGlobalEarlyTermination::slot_type const &iSlot)
std::unique_ptr< jsoncollector::FastMonitor > jsonMonitor_
static const std::string nopath_
ModuleDescription const * moduleDescription() const
void resetFastMonitor(std::string const &microStateDefPath, std::string const &fastMicroStateDefPath)
static const int nReservedModules
void watchPostGlobalEndLumi(PostGlobalEndLumi::slot_type const &iSlot)
std::map< unsigned int, std::pair< double, unsigned int > > lockStatsDuringLumi_
std::vector< unsigned long > firstEventId_
void watchPreModuleBeginJob(PreModuleBeginJob::slot_type const &iSlot)
void postModuleEvent(edm::StreamContext const &, edm::ModuleCallingContext const &)
virtual std::string write(const Value &root)
Serialize a Value in JSON format.
void postStreamBeginLumi(edm::StreamContext const &)
StreamID const & streamID() const
Definition: StreamContext.h:57
void postStreamEndLumi(edm::StreamContext const &)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< const void * > microstate_
std::vector< unsigned int > microstateEncoded_
unsigned int value() const
Definition: StreamID.h:46
std::map< unsigned int, std::pair< unsigned int, bool > > processedEventsPerLumi_
void preStreamBeginLumi(edm::StreamContext const &)
std::atomic< unsigned long > totalEventsProcessed_
FedRawDataInputSource * inputSource_
static const int nSpecialModules
LuminosityBlockNumber_t luminosityBlock() const
void watchPreStreamBeginLumi(PreStreamBeginLumi::slot_type const &iSlot)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
FastMonitoringThread::Macrostate macrostate_
std::vector< double > leadTimes_
void stoppedLookingForFile(unsigned int lumi)
void setMicroState(MicroStateService::Microstate)
void load(int perCUT=90)
Definition: getMaxPt.h:59
boost::filesystem::path workingDirectory_
std::vector< jsoncollector::AtomicMonUInt * > processed_
void postGlobalBeginRun(edm::GlobalContext const &)
void preEvent(edm::StreamContext const &)
void preSourceEarlyTermination(edm::TerminationOrigin)
EventID const & eventID() const
Definition: StreamContext.h:59
void watchPreSourceEvent(PreSourceEvent::slot_type const &iSlot)
bool getAbortFlagForLumi(unsigned int lumi)
void preModuleEvent(edm::StreamContext const &, edm::ModuleCallingContext const &)
Writes a Value in JSON format in a human friendly way.
Definition: writer.h:65
std::vector< const void * > ministate_
const void * decode(unsigned int index)
std::vector< unsigned int > streamLumi_
std::vector< Encoding > encPath_
std::vector< unsigned int > ministateEncoded_
void reportLockWait(unsigned int ls, double waitTime, unsigned int lockCount)
std::vector< unsigned int > exceptionInLS_
void watchPostBeginJob(PostBeginJob::slot_type const &iSlot)
convenience function for attaching to signal
array value (ordered list)
Definition: value.h:31