CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes
evf::FastMonitoringService Class Reference

#include <FastMonitoringService.h>

Inheritance diagram for evf::FastMonitoringService:
evf::MicroStateService

Public Member Functions

void accumulateFileSize (unsigned int lumi, unsigned long fileSize)
 
bool exceptionDetected () const
 
 FastMonitoringService (const edm::ParameterSet &, edm::ActivityRegistry &)
 
bool getAbortFlagForLumi (unsigned int lumi)
 
unsigned int getEventsProcessedForLumi (unsigned int lumi, bool *abortFlag=nullptr)
 
std::string getRunDirName () const
 
bool isExceptionOnData (unsigned int ls)
 
void jobFailure ()
 
std::string makeInputLegendaJson ()
 
std::string makeModuleLegendaJson ()
 
std::string makePathLegendaJson ()
 
void postBeginJob ()
 
void postEndJob ()
 
void postEvent (edm::StreamContext const &)
 
void postGlobalBeginRun (edm::GlobalContext const &)
 
void postGlobalEndLumi (edm::GlobalContext const &)
 
void postModuleEvent (edm::StreamContext const &, edm::ModuleCallingContext const &)
 
void postModuleEventAcquire (edm::StreamContext const &, edm::ModuleCallingContext const &)
 
void postSourceEvent (edm::StreamID)
 
void postStreamBeginLumi (edm::StreamContext const &)
 
void postStreamEndLumi (edm::StreamContext const &)
 
void preallocate (edm::service::SystemBounds const &)
 
void preBeginJob (edm::PathsAndConsumesOfModulesBase const &, edm::ProcessContext const &pc)
 
void preEvent (edm::StreamContext const &)
 
void preGlobalBeginLumi (edm::GlobalContext const &)
 
void preGlobalEarlyTermination (edm::GlobalContext const &, edm::TerminationOrigin)
 
void preGlobalEndLumi (edm::GlobalContext const &)
 
void preModuleBeginJob (edm::ModuleDescription const &)
 
void preModuleEvent (edm::StreamContext const &, edm::ModuleCallingContext const &)
 
void preModuleEventAcquire (edm::StreamContext const &, edm::ModuleCallingContext const &)
 
void prePathEvent (edm::StreamContext const &, edm::PathContext const &)
 
void preSourceEarlyTermination (edm::TerminationOrigin)
 
void preSourceEvent (edm::StreamID)
 
void preStreamBeginLumi (edm::StreamContext const &)
 
void preStreamEarlyTermination (edm::StreamContext const &, edm::TerminationOrigin)
 
void preStreamEndLumi (edm::StreamContext const &)
 
void reportLockWait (unsigned int ls, double waitTime, unsigned int lockCount)
 
void setExceptionDetected (unsigned int ls)
 
void setInputSource (FedRawDataInputSource *inputSource)
 
void setInputSource (DAQSource *inputSource)
 
void setInState (FastMonState::InputState inputState)
 
void setInStateSup (FastMonState::InputState inputState)
 
void setMicroState (FastMonState::Microstate)
 
void setMicroState (edm::StreamID, FastMonState::Microstate)
 
bool shouldWriteFiles (unsigned int lumi, unsigned int *proc=nullptr)
 
void startedLookingForFile ()
 
void stoppedLookingForFile (unsigned int lumi)
 
 ~FastMonitoringService () override
 
- Public Member Functions inherited from evf::MicroStateService
 MicroStateService (const edm::ParameterSet &, edm::ActivityRegistry &)
 
virtual ~MicroStateService ()
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Static Public Attributes

static const std::string inputStateNames [FastMonState::inCOUNT]
 
static const std::string macroStateNames [FastMonState::MCOUNT]
 
static const std::string nopath_ = "NoPath"
 
static const edm::ModuleDescription reservedMicroStateNames [FastMonState::mCOUNT]
 

Private Member Functions

void doSnapshot (const unsigned int ls, const bool isGlobalEOL)
 
void snapshotRunner ()
 

Private Attributes

std::map< unsigned int, unsigned long > accuSize_
 
std::map< unsigned int, double > avgLeadTime_
 
std::vector< std::atomic< bool > * > collectedPathList_
 
DAQSourcedaqInputSource_ = nullptr
 
bool exception_detected_ = false
 
std::vector< unsigned int > exceptionInLS_
 
std::string fastMicrostateDefPath_
 
unsigned int fastMonIntervals_
 
std::string fastName_
 
std::string fastPath_
 
std::vector< std::string > fastPathList_
 
timeval fileLookStart_
 
timeval fileLookStop_
 
bool filePerFwkStream_
 
std::map< unsigned int, unsigned int > filesProcessedDuringLumi_
 
std::shared_ptr< FastMonitoringThreadfmt_
 
std::atomic< bool > has_data_exception_ = false
 
std::atomic< bool > has_source_exception_ = false
 
std::string inputLegendFileJson_
 
FedRawDataInputSourceinputSource_ = nullptr
 
std::atomic< FastMonState::InputStateinputState_ {FastMonState::InputState::inInit}
 
std::atomic< FastMonState::InputStateinputSupervisorState_ {FastMonState::InputState::inInit}
 
std::atomic< bool > isInitTransition_
 
unsigned int lastGlobalLumi_
 
std::vector< double > leadTimes_
 
std::map< unsigned int, std::pair< double, unsigned int > > lockStatsDuringLumi_
 
unsigned int lumiFromSource_
 
std::map< unsigned int, timeval > lumiStartTime_
 
std::string microstateDefPath_
 
std::string moduleLegendFile_
 
std::string moduleLegendFileJson_
 
std::atomic< bool > monInit_
 
unsigned int nOutputModules_ = 0
 
unsigned int nStreams_
 
unsigned int nThreads_
 
std::string pathLegendFile_
 
std::string pathLegendFileJson_
 
std::vector< bool > pathNamesReady_
 
std::map< unsigned int, std::pair< unsigned int, bool > > processedEventsPerLumi_
 
std::filesystem::path runDirectory_
 
int sleepTime_
 
std::string slowName_
 
unsigned int snapCounter_ = 0
 
std::vector< std::atomic< bool > * > streamCounterUpdating_
 
bool threadIDAvailable_ = false
 
std::atomic< unsigned long > totalEventsProcessed_
 
std::filesystem::path workingDirectory_
 

Detailed Description

Definition at line 156 of file FastMonitoringService.h.

Constructor & Destructor Documentation

◆ FastMonitoringService()

evf::FastMonitoringService::FastMonitoringService ( const edm::ParameterSet iPS,
edm::ActivityRegistry reg 
)

Definition at line 126 of file FastMonitoringService.cc.

References Exception, fastMicrostateDefPath_, jobFailure(), microstateDefPath_, postBeginJob(), postEndJob(), postEvent(), postGlobalEndLumi(), postModuleEvent(), postModuleEventAcquire(), postSourceEvent(), postStreamBeginLumi(), postStreamEndLumi(), preallocate(), preBeginJob(), preEvent(), preGlobalBeginLumi(), preGlobalEarlyTermination(), preGlobalEndLumi(), preModuleBeginJob(), preModuleEvent(), preModuleEventAcquire(), prePathEvent(), preSourceEarlyTermination(), preSourceEvent(), preStreamBeginLumi(), preStreamEarlyTermination(), preStreamEndLumi(), edm_modernize_messagelogger::stat, AlCaHLTBitMon_QueryRunRegistry::string, edm::ActivityRegistry::watchJobFailure(), edm::ActivityRegistry::watchPostBeginJob(), edm::ActivityRegistry::watchPostEndJob(), edm::ActivityRegistry::watchPostEvent(), edm::ActivityRegistry::watchPostGlobalEndLumi(), edm::ActivityRegistry::watchPostModuleEvent(), edm::ActivityRegistry::watchPostModuleEventAcquire(), edm::ActivityRegistry::watchPostSourceEvent(), edm::ActivityRegistry::watchPostStreamBeginLumi(), edm::ActivityRegistry::watchPostStreamEndLumi(), edm::ActivityRegistry::watchPreallocate(), edm::ActivityRegistry::watchPreBeginJob(), edm::ActivityRegistry::watchPreEvent(), edm::ActivityRegistry::watchPreGlobalBeginLumi(), edm::ActivityRegistry::watchPreGlobalEarlyTermination(), edm::ActivityRegistry::watchPreGlobalEndLumi(), edm::ActivityRegistry::watchPreModuleBeginJob(), edm::ActivityRegistry::watchPreModuleEvent(), edm::ActivityRegistry::watchPreModuleEventAcquire(), edm::ActivityRegistry::watchPrePathEvent(), edm::ActivityRegistry::watchPreSourceEarlyTermination(), edm::ActivityRegistry::watchPreSourceEvent(), edm::ActivityRegistry::watchPreStreamBeginLumi(), edm::ActivityRegistry::watchPreStreamEarlyTermination(), and edm::ActivityRegistry::watchPreStreamEndLumi().

127  : MicroStateService(iPS, reg),
128  fmt_(new FastMonitoringThread()),
129  nStreams_(0) //until initialized
130  ,
131  sleepTime_(iPS.getUntrackedParameter<int>("sleepTime", 1)),
132  fastMonIntervals_(iPS.getUntrackedParameter<unsigned int>("fastMonIntervals", 2)),
133  fastName_("fastmoni"),
134  slowName_("slowmoni"),
135  filePerFwkStream_(iPS.getUntrackedParameter<bool>("filePerFwkStream", false)),
137  reg.watchPreallocate(this, &FastMonitoringService::preallocate); //receiving information on number of threads
139 
144 
148 
153 
155 
156  reg.watchPreEvent(this, &FastMonitoringService::preEvent); //stream
158 
159  reg.watchPreSourceEvent(this, &FastMonitoringService::preSourceEvent); //source (with streamID of requestor)
161 
164 
167 
171 
172  //find microstate definition path (required by the module)
173  struct stat statbuf;
174  std::string microstateBaseSuffix = "src/EventFilter/Utilities/plugins/microstatedef.jsd";
175  std::string microstatePath = std::string(std::getenv("CMSSW_BASE")) + "/" + microstateBaseSuffix;
176  if (stat(microstatePath.c_str(), &statbuf)) {
177  microstatePath = std::string(std::getenv("CMSSW_RELEASE_BASE")) + "/" + microstateBaseSuffix;
178  if (stat(microstatePath.c_str(), &statbuf)) {
179  microstatePath = microstateBaseSuffix;
180  if (stat(microstatePath.c_str(), &statbuf))
181  throw cms::Exception("FastMonitoringService") << "microstate definition file not found";
182  }
183  }
184  fastMicrostateDefPath_ = microstateDefPath_ = microstatePath;
185  }
void prePathEvent(edm::StreamContext const &, edm::PathContext const &)
void watchPreStreamEarlyTermination(PreStreamEarlyTermination::slot_type const &iSlot)
void watchPreEvent(PreEvent::slot_type const &iSlot)
void postModuleEventAcquire(edm::StreamContext const &, edm::ModuleCallingContext const &)
void watchPrePathEvent(PrePathEvent::slot_type const &iSlot)
void watchPreallocate(Preallocate::slot_type const &iSlot)
void watchPreModuleEventAcquire(PreModuleEventAcquire::slot_type const &iSlot)
void watchPostEndJob(PostEndJob::slot_type const &iSlot)
void preallocate(edm::service::SystemBounds const &)
void preGlobalBeginLumi(edm::GlobalContext const &)
void watchPreModuleEvent(PreModuleEvent::slot_type const &iSlot)
void postGlobalEndLumi(edm::GlobalContext const &)
void postEvent(edm::StreamContext const &)
void watchPreGlobalEndLumi(PreGlobalEndLumi::slot_type const &iSlot)
void watchPostEvent(PostEvent::slot_type const &iSlot)
void watchPostStreamEndLumi(PostStreamEndLumi::slot_type const &iSlot)
void watchPreGlobalBeginLumi(PreGlobalBeginLumi::slot_type const &iSlot)
void watchPostModuleEvent(PostModuleEvent::slot_type const &iSlot)
void watchPostSourceEvent(PostSourceEvent::slot_type const &iSlot)
void preGlobalEndLumi(edm::GlobalContext const &)
void watchPreStreamEndLumi(PreStreamEndLumi::slot_type const &iSlot)
void preGlobalEarlyTermination(edm::GlobalContext const &, edm::TerminationOrigin)
void watchPreSourceEarlyTermination(PreSourceEarlyTermination::slot_type const &iSlot)
void watchJobFailure(JobFailure::slot_type const &iSlot)
convenience function for attaching to signal
T getUntrackedParameter(std::string const &, T const &) const
void preModuleBeginJob(edm::ModuleDescription const &)
MicroStateService(const edm::ParameterSet &, edm::ActivityRegistry &)
void preStreamEndLumi(edm::StreamContext const &)
void watchPostStreamBeginLumi(PostStreamBeginLumi::slot_type const &iSlot)
void preStreamEarlyTermination(edm::StreamContext const &, edm::TerminationOrigin)
void watchPreGlobalEarlyTermination(PreGlobalEarlyTermination::slot_type const &iSlot)
void watchPostModuleEventAcquire(PostModuleEventAcquire::slot_type const &iSlot)
void watchPostGlobalEndLumi(PostGlobalEndLumi::slot_type const &iSlot)
void watchPreModuleBeginJob(PreModuleBeginJob::slot_type const &iSlot)
void preModuleEventAcquire(edm::StreamContext const &, edm::ModuleCallingContext const &)
void postModuleEvent(edm::StreamContext const &, edm::ModuleCallingContext const &)
void postStreamBeginLumi(edm::StreamContext const &)
void postStreamEndLumi(edm::StreamContext const &)
void preStreamBeginLumi(edm::StreamContext const &)
std::atomic< unsigned long > totalEventsProcessed_
void watchPreStreamBeginLumi(PreStreamBeginLumi::slot_type const &iSlot)
void preBeginJob(edm::PathsAndConsumesOfModulesBase const &, edm::ProcessContext const &pc)
void watchPreBeginJob(PreBeginJob::slot_type const &iSlot)
convenience function for attaching to signal
void preEvent(edm::StreamContext const &)
void preSourceEarlyTermination(edm::TerminationOrigin)
void watchPreSourceEvent(PreSourceEvent::slot_type const &iSlot)
std::shared_ptr< FastMonitoringThread > fmt_
void preModuleEvent(edm::StreamContext const &, edm::ModuleCallingContext const &)
void watchPostBeginJob(PostBeginJob::slot_type const &iSlot)
convenience function for attaching to signal

◆ ~FastMonitoringService()

evf::FastMonitoringService::~FastMonitoringService ( )
override

Definition at line 187 of file FastMonitoringService.cc.

187 {}

Member Function Documentation

◆ accumulateFileSize()

void evf::FastMonitoringService::accumulateFileSize ( unsigned int  lumi,
unsigned long  fileSize 
)

Definition at line 695 of file FastMonitoringService.cc.

References accuSize_, filesProcessedDuringLumi_, fmt_, CommonMethods::lock(), and BXlumiParameters_cfi::lumi.

Referenced by evf::EvFDaqDirector::bumpFile().

695  {
696  std::lock_guard<std::mutex> lock(fmt_->monlock_);
697 
698  if (accuSize_.find(lumi) == accuSize_.end())
699  accuSize_[lumi] = fileSize;
700  else
701  accuSize_[lumi] += fileSize;
702 
705  else
707  }
std::map< unsigned int, unsigned long > accuSize_
std::map< unsigned int, unsigned int > filesProcessedDuringLumi_
std::shared_ptr< FastMonitoringThread > fmt_

◆ doSnapshot()

void evf::FastMonitoringService::doSnapshot ( const unsigned int  ls,
const bool  isGlobalEOL 
)
private

Definition at line 844 of file FastMonitoringService.cc.

References avgLeadTime_, filesProcessedDuringLumi_, fmt_, mps_fire::i, caHitNtupletGeneratorKernels::if(), evf::FastMonState::inNewLumi, evf::FastMonState::inNoRequest, evf::FastMonState::inNoRequestWithEoLThreads, evf::FastMonState::inNoRequestWithIdleThreads, inputState_, inputSupervisorState_, evf::FastMonState::inRunEnd, evf::FastMonState::inSupBusy, evf::FastMonState::inSupFileLimit, evf::FastMonState::inSupLockPolling, evf::FastMonState::inSupLockPollingCopying, evf::FastMonState::inSupNewFile, evf::FastMonState::inSupNewFileWaitChunk, evf::FastMonState::inSupNewFileWaitChunkCopying, evf::FastMonState::inSupNewFileWaitThread, evf::FastMonState::inSupNewFileWaitThreadCopying, evf::FastMonState::inSupNoFile, evf::FastMonState::inSupThrottled, evf::FastMonState::inSupWaitFreeChunk, evf::FastMonState::inSupWaitFreeChunkCopying, evf::FastMonState::inSupWaitFreeThread, evf::FastMonState::inSupWaitFreeThreadCopying, evf::FastMonState::inWaitChunk, evf::FastMonState::inWaitChunk_busy, evf::FastMonState::inWaitChunk_fileLimit, evf::FastMonState::inWaitChunk_lockPolling, evf::FastMonState::inWaitChunk_lockPollingCopying, evf::FastMonState::inWaitChunk_newFile, evf::FastMonState::inWaitChunk_newFileWaitChunk, evf::FastMonState::inWaitChunk_newFileWaitChunkCopying, evf::FastMonState::inWaitChunk_newFileWaitThread, evf::FastMonState::inWaitChunk_newFileWaitThreadCopying, evf::FastMonState::inWaitChunk_noFile, evf::FastMonState::inWaitChunk_runEnd, evf::FastMonState::inWaitChunk_waitFreeChunk, evf::FastMonState::inWaitChunk_waitFreeChunkCopying, evf::FastMonState::inWaitChunk_waitFreeThread, evf::FastMonState::inWaitChunk_waitFreeThreadCopying, evf::FastMonState::inWaitInput, evf::FastMonState::inWaitInput_busy, evf::FastMonState::inWaitInput_fileLimit, evf::FastMonState::inWaitInput_lockPolling, evf::FastMonState::inWaitInput_lockPollingCopying, evf::FastMonState::inWaitInput_newFile, evf::FastMonState::inWaitInput_newFileWaitChunk, evf::FastMonState::inWaitInput_newFileWaitChunkCopying, evf::FastMonState::inWaitInput_newFileWaitThread, evf::FastMonState::inWaitInput_newFileWaitThreadCopying, evf::FastMonState::inWaitInput_noFile, evf::FastMonState::inWaitInput_runEnd, evf::FastMonState::inWaitInput_waitFreeChunk, evf::FastMonState::inWaitInput_waitFreeChunkCopying, evf::FastMonState::inWaitInput_waitFreeThread, evf::FastMonState::inWaitInput_waitFreeThreadCopying, isInitTransition_, lockStatsDuringLumi_, eostools::ls(), evf::FastMonState::mEoL, evf::FastMonState::mFwkEoL, evf::FastMonState::mIdle, nStreams_, and reservedMicroStateNames.

Referenced by preGlobalEndLumi(), and snapshotRunner().

844  {
845  // update macrostate
846  fmt_->m_data.fastMacrostateJ_ = fmt_->m_data.macrostate_;
847 
848  std::vector<const void*> microstateCopy(fmt_->m_data.microstate_.begin(), fmt_->m_data.microstate_.end());
849  std::vector<unsigned char> microstateAcqCopy(fmt_->m_data.microstateAcqFlag_.begin(),
850  fmt_->m_data.microstateAcqFlag_.end());
851 
852  if (!isInitTransition_) {
853  auto itd = avgLeadTime_.find(ls);
854  if (itd != avgLeadTime_.end())
855  fmt_->m_data.fastAvgLeadTimeJ_ = itd->second;
856  else
857  fmt_->m_data.fastAvgLeadTimeJ_ = 0.;
858 
859  auto iti = filesProcessedDuringLumi_.find(ls);
860  if (iti != filesProcessedDuringLumi_.end())
861  fmt_->m_data.fastFilesProcessedJ_ = iti->second;
862  else
863  fmt_->m_data.fastFilesProcessedJ_ = 0;
864 
865  auto itrd = lockStatsDuringLumi_.find(ls);
866  if (itrd != lockStatsDuringLumi_.end()) {
867  fmt_->m_data.fastLockWaitJ_ = itrd->second.first;
868  fmt_->m_data.fastLockCountJ_ = itrd->second.second;
869  } else {
870  fmt_->m_data.fastLockWaitJ_ = 0.;
871  fmt_->m_data.fastLockCountJ_ = 0.;
872  }
873  }
874 
875  for (unsigned int i = 0; i < nStreams_; i++) {
876  fmt_->m_data.ministateEncoded_[i] = fmt_->m_data.encPath_[i].encodeString(fmt_->m_data.ministate_[i]);
877  if (microstateAcqCopy[i])
878  fmt_->m_data.microstateEncoded_[i] =
879  fmt_->m_data.microstateBins_ + fmt_->m_data.encModule_.encode(microstateCopy[i]);
880  else
881  fmt_->m_data.microstateEncoded_[i] = fmt_->m_data.encModule_.encode(microstateCopy[i]);
882  }
883 
884  bool inputStatePerThread = false;
885 
887  switch (inputSupervisorState_) {
889  fmt_->m_data.inputState_[0] = FastMonState::inWaitInput_fileLimit;
890  break;
892  fmt_->m_data.inputState_[0] = FastMonState::inWaitInput_waitFreeChunk;
893  break;
895  fmt_->m_data.inputState_[0] = FastMonState::inWaitInput_waitFreeChunkCopying;
896  break;
898  fmt_->m_data.inputState_[0] = FastMonState::inWaitInput_waitFreeThread;
899  break;
901  fmt_->m_data.inputState_[0] = FastMonState::inWaitInput_waitFreeThreadCopying;
902  break;
904  fmt_->m_data.inputState_[0] = FastMonState::inWaitInput_busy;
905  break;
907  fmt_->m_data.inputState_[0] = FastMonState::inWaitInput_lockPolling;
908  break;
910  fmt_->m_data.inputState_[0] = FastMonState::inWaitInput_lockPollingCopying;
911  break;
913  fmt_->m_data.inputState_[0] = FastMonState::inWaitInput_runEnd;
914  break;
916  fmt_->m_data.inputState_[0] = FastMonState::inWaitInput_noFile;
917  break;
919  fmt_->m_data.inputState_[0] = FastMonState::inWaitInput_newFile;
920  break;
923  break;
925  fmt_->m_data.inputState_[0] = FastMonState::inWaitInput_newFileWaitThread;
926  break;
929  break;
931  fmt_->m_data.inputState_[0] = FastMonState::inWaitInput_newFileWaitChunk;
932  break;
933  default:
934  fmt_->m_data.inputState_[0] = FastMonState::inWaitInput;
935  }
936  } else if (inputState_ == FastMonState::inWaitChunk) {
937  switch (inputSupervisorState_) {
939  fmt_->m_data.inputState_[0] = FastMonState::inWaitChunk_fileLimit;
940  break;
942  fmt_->m_data.inputState_[0] = FastMonState::inWaitChunk_waitFreeChunk;
943  break;
945  fmt_->m_data.inputState_[0] = FastMonState::inWaitChunk_waitFreeChunkCopying;
946  break;
948  fmt_->m_data.inputState_[0] = FastMonState::inWaitChunk_waitFreeThread;
949  break;
951  fmt_->m_data.inputState_[0] = FastMonState::inWaitChunk_waitFreeThreadCopying;
952  break;
954  fmt_->m_data.inputState_[0] = FastMonState::inWaitChunk_busy;
955  break;
957  fmt_->m_data.inputState_[0] = FastMonState::inWaitChunk_lockPolling;
958  break;
960  fmt_->m_data.inputState_[0] = FastMonState::inWaitChunk_lockPollingCopying;
961  break;
963  fmt_->m_data.inputState_[0] = FastMonState::inWaitChunk_runEnd;
964  break;
966  fmt_->m_data.inputState_[0] = FastMonState::inWaitChunk_noFile;
967  break;
969  fmt_->m_data.inputState_[0] = FastMonState::inWaitChunk_newFile;
970  break;
973  break;
975  fmt_->m_data.inputState_[0] = FastMonState::inWaitChunk_newFileWaitThread;
976  break;
979  break;
981  fmt_->m_data.inputState_[0] = FastMonState::inWaitChunk_newFileWaitChunk;
982  break;
983  default:
984  fmt_->m_data.inputState_[0] = FastMonState::inWaitChunk;
985  }
986  } else if (inputState_ == FastMonState::inNoRequest) {
987  inputStatePerThread = true;
988  for (unsigned int i = 0; i < nStreams_; i++) {
989  if (microstateCopy[i] == &reservedMicroStateNames[FastMonState::mIdle])
990  fmt_->m_data.inputState_[i] = FastMonState::inNoRequestWithIdleThreads;
991  else if (microstateCopy[i] == &reservedMicroStateNames[FastMonState::mEoL] ||
992  microstateCopy[i] == &reservedMicroStateNames[FastMonState::mFwkEoL])
993  fmt_->m_data.inputState_[i] = FastMonState::inNoRequestWithEoLThreads;
994  else
995  fmt_->m_data.inputState_[i] = FastMonState::inNoRequest;
996  }
997  } else if (inputState_ == FastMonState::inNewLumi) {
998  inputStatePerThread = true;
999  for (unsigned int i = 0; i < nStreams_; i++) {
1000  if (microstateCopy[i] == &reservedMicroStateNames[FastMonState::mEoL] ||
1001  microstateCopy[i] == &reservedMicroStateNames[FastMonState::mFwkEoL])
1002  fmt_->m_data.inputState_[i] = FastMonState::inNewLumi;
1003  }
1005  //apply directly throttled state from supervisor
1006  fmt_->m_data.inputState_[0] = inputSupervisorState_;
1007  } else
1008  fmt_->m_data.inputState_[0] = inputState_;
1009 
1010  //this is same for all streams
1011  if (!inputStatePerThread)
1012  for (unsigned int i = 1; i < nStreams_; i++)
1013  fmt_->m_data.inputState_[i] = fmt_->m_data.inputState_[0];
1014 
1015  if (isGlobalEOL) { //only update global variables
1016  fmt_->jsonMonitor_->snapGlobal(ls);
1017  } else
1018  fmt_->jsonMonitor_->snap(ls);
1019  }
std::atomic< FastMonState::InputState > inputState_
std::atomic< bool > isInitTransition_
std::map< unsigned int, unsigned int > filesProcessedDuringLumi_
static const edm::ModuleDescription reservedMicroStateNames[FastMonState::mCOUNT]
std::map< unsigned int, double > avgLeadTime_
std::atomic< FastMonState::InputState > inputSupervisorState_
def ls(path, rec=False)
Definition: eostools.py:349
std::map< unsigned int, std::pair< double, unsigned int > > lockStatsDuringLumi_
std::shared_ptr< FastMonitoringThread > fmt_

◆ exceptionDetected()

bool evf::FastMonitoringService::exceptionDetected ( ) const

Definition at line 432 of file FastMonitoringService.cc.

References has_data_exception_, and has_source_exception_.

Referenced by DAQSource::~DAQSource(), and FedRawDataInputSource::~FedRawDataInputSource().

432  {
433  return has_source_exception_.load() || has_data_exception_.load();
434  }
std::atomic< bool > has_data_exception_
std::atomic< bool > has_source_exception_

◆ fillDescriptions()

void evf::FastMonitoringService::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 189 of file FastMonitoringService.cc.

References edm::ConfigurationDescriptions::add(), and submitPVResolutionJobs::desc.

189  {
191  desc.setComment("Service for File-based DAQ monitoring and event accounting");
192  desc.addUntracked<int>("sleepTime", 1)->setComment("Sleep time of the monitoring thread");
193  desc.addUntracked<unsigned int>("fastMonIntervals", 2)
194  ->setComment("Modulo of sleepTime intervals on which fastmon file is written out");
195  desc.addUntracked<bool>("filePerFwkStream", false)
196  ->setComment("Switches on monitoring output per framework stream");
197  desc.setAllowAnything();
198  descriptions.add("FastMonitoringService", desc);
199  }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ getAbortFlagForLumi()

bool evf::FastMonitoringService::getAbortFlagForLumi ( unsigned int  lumi)

Definition at line 769 of file FastMonitoringService.cc.

References Exception, fmt_, CommonMethods::lock(), BXlumiParameters_cfi::lumi, and processedEventsPerLumi_.

Referenced by shouldWriteFiles().

769  {
770  std::lock_guard<std::mutex> lock(fmt_->monlock_);
771 
772  auto it = processedEventsPerLumi_.find(lumi);
773  if (it != processedEventsPerLumi_.end()) {
774  unsigned int abortFlag = it->second.second;
775  return abortFlag;
776  } else {
777  throw cms::Exception("FastMonitoringService")
778  << "output module wants already deleted (or never reported by SOURCE) lumisection status for LUMI -: "
779  << lumi;
780  return false;
781  }
782  }
std::map< unsigned int, std::pair< unsigned int, bool > > processedEventsPerLumi_
std::shared_ptr< FastMonitoringThread > fmt_

◆ getEventsProcessedForLumi()

unsigned int evf::FastMonitoringService::getEventsProcessedForLumi ( unsigned int  lumi,
bool *  abortFlag = nullptr 
)

Definition at line 751 of file FastMonitoringService.cc.

References Exception, fmt_, CommonMethods::lock(), BXlumiParameters_cfi::lumi, ValidateTausOnZEEFastSim_cff::proc, and processedEventsPerLumi_.

Referenced by dqm::DQMFileSaverPB::fillJson(), dqmfilesaver::fillJson(), evf::EvFOutputModule::globalEndLuminosityBlock(), evf::GlobalEvFOutputModule::globalEndLuminosityBlock(), dqm::DQMFileSaverPB::saveLumi(), and shouldWriteFiles().

751  {
752  std::lock_guard<std::mutex> lock(fmt_->monlock_);
753 
754  auto it = processedEventsPerLumi_.find(lumi);
755  if (it != processedEventsPerLumi_.end()) {
756  unsigned int proc = it->second.first;
757  if (abortFlag)
758  *abortFlag = it->second.second;
759  return proc;
760  } else {
761  throw cms::Exception("FastMonitoringService")
762  << "output module wants already deleted (or never reported by SOURCE) lumisection event count for LUMI -: "
763  << lumi;
764  return 0;
765  }
766  }
std::map< unsigned int, std::pair< unsigned int, bool > > processedEventsPerLumi_
std::shared_ptr< FastMonitoringThread > fmt_

◆ getRunDirName()

std::string evf::FastMonitoringService::getRunDirName ( ) const
inline

Definition at line 221 of file FastMonitoringService.h.

References runDirectory_.

221 { return runDirectory_.stem().string(); }
std::filesystem::path runDirectory_

◆ isExceptionOnData()

bool evf::FastMonitoringService::isExceptionOnData ( unsigned int  ls)

Definition at line 436 of file FastMonitoringService.cc.

References exceptionInLS_, fmt_, has_data_exception_, has_source_exception_, CommonMethods::lock(), and eostools::ls().

Referenced by evf::EvFDaqDirector::preGlobalEndLumi(), FedRawDataInputSource::read(), DAQSource::read(), DAQSource::~DAQSource(), and FedRawDataInputSource::~FedRawDataInputSource().

436  {
437  if (!has_data_exception_.load())
438  return false;
439  if (has_source_exception_.load())
440  return true;
441  std::lock_guard<std::mutex> lock(fmt_->monlock_);
442  for (auto ex : exceptionInLS_) {
443  if (ls == ex)
444  return true;
445  }
446  return false;
447  }
std::atomic< bool > has_data_exception_
def ls(path, rec=False)
Definition: eostools.py:349
std::atomic< bool > has_source_exception_
std::shared_ptr< FastMonitoringThread > fmt_
std::vector< unsigned int > exceptionInLS_

◆ jobFailure()

void evf::FastMonitoringService::jobFailure ( )

Definition at line 449 of file FastMonitoringService.cc.

References fmt_, and evf::FastMonState::sError.

Referenced by FastMonitoringService().

449 { fmt_->m_data.macrostate_ = FastMonState::sError; }
std::shared_ptr< FastMonitoringThread > fmt_

◆ makeInputLegendaJson()

std::string evf::FastMonitoringService::makeInputLegendaJson ( )

Definition at line 234 of file FastMonitoringService.cc.

References Json::Value::append(), Json::arrayValue, mps_fire::i, evf::FastMonState::inCOUNT, inputStateNames, and convertToRaw::writer.

Referenced by postBeginJob().

234  {
235  Json::Value legendaVector(Json::arrayValue);
236  for (int i = 0; i < FastMonState::inCOUNT; i++)
237  legendaVector.append(Json::Value(inputStateNames[i]));
238  Json::Value moduleLegend;
239  moduleLegend["names"] = legendaVector;
241  return writer.write(moduleLegend);
242  }
static const std::string inputStateNames[FastMonState::inCOUNT]
Represents a JSON value.
Definition: value.h:99
Writes a Value in JSON format in a human friendly way.
Definition: writer.h:63
array value (ordered list)
Definition: value.h:30

◆ makeModuleLegendaJson()

std::string evf::FastMonitoringService::makeModuleLegendaJson ( )

Definition at line 213 of file FastMonitoringService.cc.

References Json::Value::append(), Json::arrayValue, fmt_, mps_fire::i, nOutputModules_, evf::nReservedModules, evf::nSpecialModules, and convertToRaw::writer.

Referenced by postBeginJob().

213  {
214  Json::Value legendaVector(Json::arrayValue);
215  for (int i = 0; i < fmt_->m_data.encModule_.current_; i++)
216  legendaVector.append(
217  Json::Value((static_cast<const edm::ModuleDescription*>(fmt_->m_data.encModule_.decode(i)))->moduleLabel()));
218  //duplicate modules adding a list for acquire states (not all modules actually have it)
219  for (int i = 0; i < fmt_->m_data.encModule_.current_; i++)
220  legendaVector.append(Json::Value(
221  (static_cast<const edm::ModuleDescription*>(fmt_->m_data.encModule_.decode(i)))->moduleLabel() + "__ACQ"));
222  Json::Value valReserved(nReservedModules);
223  Json::Value valSpecial(nSpecialModules);
224  Json::Value valOutputModules(nOutputModules_);
225  Json::Value moduleLegend;
226  moduleLegend["names"] = legendaVector;
227  moduleLegend["reserved"] = valReserved;
228  moduleLegend["special"] = valSpecial;
229  moduleLegend["output"] = valOutputModules;
231  return writer.write(moduleLegend);
232  }
Represents a JSON value.
Definition: value.h:99
constexpr int nSpecialModules
constexpr int nReservedModules
std::shared_ptr< FastMonitoringThread > fmt_
Writes a Value in JSON format in a human friendly way.
Definition: writer.h:63
array value (ordered list)
Definition: value.h:30

◆ makePathLegendaJson()

std::string evf::FastMonitoringService::makePathLegendaJson ( )

Definition at line 201 of file FastMonitoringService.cc.

References Json::Value::append(), Json::arrayValue, fmt_, mps_fire::i, evf::nReservedPaths, and convertToRaw::writer.

Referenced by postBeginJob().

201  {
202  Json::Value legendaVector(Json::arrayValue);
203  for (int i = 0; i < fmt_->m_data.encPath_[0].current_; i++)
204  legendaVector.append(Json::Value(*(static_cast<const std::string*>(fmt_->m_data.encPath_[0].decode(i)))));
205  Json::Value valReserved(nReservedPaths);
206  Json::Value pathLegend;
207  pathLegend["names"] = legendaVector;
208  pathLegend["reserved"] = valReserved;
210  return writer.write(pathLegend);
211  }
Represents a JSON value.
Definition: value.h:99
constexpr int nReservedPaths
std::shared_ptr< FastMonitoringThread > fmt_
Writes a Value in JSON format in a human friendly way.
Definition: writer.h:63
array value (ordered list)
Definition: value.h:30

◆ postBeginJob()

void evf::FastMonitoringService::postBeginJob ( )

Definition at line 467 of file FastMonitoringService.cc.

References fmt_, inputLegendFileJson_, CommonMethods::lock(), makeInputLegendaJson(), makeModuleLegendaJson(), makePathLegendaJson(), moduleLegendFileJson_, pathLegendFileJson_, evf::FastMonState::sJobReady, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by FastMonitoringService().

467  {
468  std::string&& moduleLegStrJson = makeModuleLegendaJson();
469  FileIO::writeStringToFile(moduleLegendFileJson_, moduleLegStrJson);
470 
471  std::string inputLegendStrJson = makeInputLegendaJson();
472  FileIO::writeStringToFile(inputLegendFileJson_, inputLegendStrJson);
473 
474  std::string pathLegendStrJson = makePathLegendaJson();
475  FileIO::writeStringToFile(pathLegendFileJson_, pathLegendStrJson);
476 
477  fmt_->m_data.macrostate_ = FastMonState::sJobReady;
478 
479  //update number of entries in module histogram
480  std::lock_guard<std::mutex> lock(fmt_->monlock_);
481  //double the size to add post-acquire states
482  fmt_->m_data.microstateBins_ = fmt_->m_data.encModule_.vecsize() * 2;
483  }
std::shared_ptr< FastMonitoringThread > fmt_

◆ postEndJob()

void evf::FastMonitoringService::postEndJob ( )

Definition at line 485 of file FastMonitoringService.cc.

References fmt_, and evf::FastMonState::sJobEnded.

Referenced by FastMonitoringService().

485  {
486  fmt_->m_data.macrostate_ = FastMonState::sJobEnded;
487  fmt_->stop();
488  }
std::shared_ptr< FastMonitoringThread > fmt_

◆ postEvent()

void evf::FastMonitoringService::postEvent ( edm::StreamContext const &  sc)

Definition at line 640 of file FastMonitoringService.cc.

References fmt_, evf::FastMonState::mIdle, nopath_, reservedMicroStateNames, edm::StreamContext::streamID(), and totalEventsProcessed_.

Referenced by FastMonitoringService().

640  {
641  fmt_->m_data.microstate_[sc.streamID()] = &reservedMicroStateNames[FastMonState::mIdle];
642 
643  fmt_->m_data.ministate_[sc.streamID()] = &nopath_;
644 
645  (*(fmt_->m_data.processed_[sc.streamID()]))++;
646 
647  //fast path counter (events accumulated in a run)
648  unsigned long res = totalEventsProcessed_.fetch_add(1, std::memory_order_relaxed);
649  fmt_->m_data.fastPathProcessedJ_ = res + 1;
650  }
static const edm::ModuleDescription reservedMicroStateNames[FastMonState::mCOUNT]
Definition: Electron.h:6
static const std::string nopath_
std::atomic< unsigned long > totalEventsProcessed_
std::shared_ptr< FastMonitoringThread > fmt_

◆ postGlobalBeginRun()

void evf::FastMonitoringService::postGlobalBeginRun ( edm::GlobalContext const &  gc)

Definition at line 490 of file FastMonitoringService.cc.

References fmt_, isInitTransition_, and evf::FastMonState::sRunning.

490  {
491  fmt_->m_data.macrostate_ = FastMonState::sRunning;
492  isInitTransition_ = false;
493  }
std::atomic< bool > isInitTransition_
std::shared_ptr< FastMonitoringThread > fmt_

◆ postGlobalEndLumi()

void evf::FastMonitoringService::postGlobalEndLumi ( edm::GlobalContext const &  gc)

Definition at line 590 of file FastMonitoringService.cc.

References avgLeadTime_, filesProcessedDuringLumi_, fmt_, CommonMethods::lock(), lockStatsDuringLumi_, edm::LuminosityBlockID::luminosityBlock(), edm::GlobalContext::luminosityBlockID(), and processedEventsPerLumi_.

Referenced by FastMonitoringService().

590  {
591  std::lock_guard<std::mutex> lock(fmt_->monlock_);
592  unsigned int lumi = gc.luminosityBlockID().luminosityBlock();
593  //LS monitoring snapshot with input source data has been taken in previous callback
594  avgLeadTime_.erase(lumi);
596  lockStatsDuringLumi_.erase(lumi);
597 
598  //output module already used this in end lumi (this could be migrated to EvFDaqDirector as it is essential for FFF bookkeeping)
600  }
std::map< unsigned int, unsigned int > filesProcessedDuringLumi_
std::map< unsigned int, std::pair< unsigned int, bool > > processedEventsPerLumi_
std::map< unsigned int, double > avgLeadTime_
std::map< unsigned int, std::pair< double, unsigned int > > lockStatsDuringLumi_
std::shared_ptr< FastMonitoringThread > fmt_

◆ postModuleEvent()

void evf::FastMonitoringService::postModuleEvent ( edm::StreamContext const &  sc,
edm::ModuleCallingContext const &  mcc 
)

Definition at line 676 of file FastMonitoringService.cc.

References fmt_, evf::FastMonState::mFwkOvhMod, reservedMicroStateNames, edm::StreamContext::streamID(), and edm::StreamID::value().

Referenced by FastMonitoringService().

676  {
677  fmt_->m_data.microstate_[sc.streamID().value()] = &reservedMicroStateNames[FastMonState::mFwkOvhMod];
678  }
static const edm::ModuleDescription reservedMicroStateNames[FastMonState::mCOUNT]
std::shared_ptr< FastMonitoringThread > fmt_

◆ postModuleEventAcquire()

void evf::FastMonitoringService::postModuleEventAcquire ( edm::StreamContext const &  sc,
edm::ModuleCallingContext const &  mcc 
)

Definition at line 665 of file FastMonitoringService.cc.

References fmt_, edm::StreamContext::streamID(), and edm::StreamID::value().

Referenced by FastMonitoringService().

666  {
667  //fmt_->m_data.microstate_[sc.streamID().value()] = (void*)(mcc.moduleDescription());
668  fmt_->m_data.microstateAcqFlag_[sc.streamID().value()] = 1;
669  }
std::shared_ptr< FastMonitoringThread > fmt_

◆ postSourceEvent()

void evf::FastMonitoringService::postSourceEvent ( edm::StreamID  sid)

Definition at line 656 of file FastMonitoringService.cc.

References fmt_, evf::FastMonState::mFwkOvhSrc, reservedMicroStateNames, and edm::StreamID::value().

Referenced by FastMonitoringService().

656  {
657  fmt_->m_data.microstate_[sid.value()] = &reservedMicroStateNames[FastMonState::mFwkOvhSrc];
658  }
static const edm::ModuleDescription reservedMicroStateNames[FastMonState::mCOUNT]
unsigned int value() const
Definition: StreamID.h:43
std::shared_ptr< FastMonitoringThread > fmt_

◆ postStreamBeginLumi()

void evf::FastMonitoringService::postStreamBeginLumi ( edm::StreamContext const &  sc)

Definition at line 615 of file FastMonitoringService.cc.

References fmt_, evf::FastMonState::mIdle, reservedMicroStateNames, edm::StreamContext::streamID(), and edm::StreamID::value().

Referenced by FastMonitoringService().

615  {
616  fmt_->m_data.microstate_[sc.streamID().value()] = &reservedMicroStateNames[FastMonState::mIdle];
617  }
static const edm::ModuleDescription reservedMicroStateNames[FastMonState::mCOUNT]
std::shared_ptr< FastMonitoringThread > fmt_

◆ postStreamEndLumi()

void evf::FastMonitoringService::postStreamEndLumi ( edm::StreamContext const &  sc)

Definition at line 630 of file FastMonitoringService.cc.

References fmt_, evf::FastMonState::mFwkEoL, reservedMicroStateNames, edm::StreamContext::streamID(), and edm::StreamID::value().

Referenced by FastMonitoringService().

630  {
631  fmt_->m_data.microstate_[sc.streamID().value()] = &reservedMicroStateNames[FastMonState::mFwkEoL];
632  }
static const edm::ModuleDescription reservedMicroStateNames[FastMonState::mCOUNT]
std::shared_ptr< FastMonitoringThread > fmt_

◆ preallocate()

void evf::FastMonitoringService::preallocate ( edm::service::SystemBounds const &  bounds)

Definition at line 244 of file FastMonitoringService.cc.

References nStreams_, and nThreads_.

Referenced by FastMonitoringService().

244  {
245  nStreams_ = bounds.maxNumberOfStreams();
246  nThreads_ = bounds.maxNumberOfThreads();
247  //this should already be >=1
248  if (nStreams_ == 0)
249  nStreams_ = 1;
250  if (nThreads_ == 0)
251  nThreads_ = 1;
252  }

◆ preBeginJob()

void evf::FastMonitoringService::preBeginJob ( edm::PathsAndConsumesOfModulesBase const &  pathsInfo,
edm::ProcessContext const &  pc 
)

Definition at line 254 of file FastMonitoringService.cc.

References edm::PathsAndConsumesOfModulesBase::endPaths(), Exception, fastMicrostateDefPath_, fastName_, fastPath_, fastPathList_, filePerFwkStream_, fmt_, mps_fire::i, evf::FastMonState::inCOUNT, inputLegendFileJson_, isInitTransition_, lastGlobalLumi_, LogDebug, lumiFromSource_, evf::FastMonState::mCOUNT, evf::FastMonState::MCOUNT, microstateDefPath_, evf::FastMonState::mInvalid, moduleLegendFile_, moduleLegendFileJson_, monInit_, nopath_, nStreams_, nThreads_, Utilities::operator, castor_dqm_sourceclient_file_cfg::path, pathLegendFile_, pathLegendFileJson_, edm::PathsAndConsumesOfModulesBase::paths(), reservedMicroStateNames, runDirectory_, evf::FastMonState::sInit, sleepTime_, snapshotRunner(), streamCounterUpdating_, threadIDAvailable_, and workingDirectory_.

Referenced by FastMonitoringService().

255  {
256  // FIND RUN DIRECTORY
257  // The run dir should be set via the configuration of EvFDaqDirector
258 
259  if (edm::Service<evf::EvFDaqDirector>().operator->() == nullptr) {
260  throw cms::Exception("FastMonitoringService") << "EvFDaqDirector is not present";
261  }
262  std::filesystem::path runDirectory{edm::Service<evf::EvFDaqDirector>()->baseRunDir()};
263  workingDirectory_ = runDirectory_ = runDirectory;
264  workingDirectory_ /= "mon";
265 
266  if (!std::filesystem::is_directory(workingDirectory_)) {
267  LogDebug("FastMonitoringService") << "<MON> DIR NOT FOUND! Trying to create -: " << workingDirectory_.string();
268  std::filesystem::create_directories(workingDirectory_);
269  if (!std::filesystem::is_directory(workingDirectory_))
270  edm::LogWarning("FastMonitoringService") << "Unable to create <MON> DIR -: " << workingDirectory_.string()
271  << ". No monitoring data will be written.";
272  }
273 
274  std::ostringstream fastFileName;
275 
276  fastFileName << fastName_ << "_pid" << std::setfill('0') << std::setw(5) << getpid() << ".fast";
278  fast /= fastFileName.str();
279  fastPath_ = fast.string();
280  if (filePerFwkStream_)
281  for (unsigned int i = 0; i < nStreams_; i++) {
282  std::ostringstream fastFileNameTid;
283  fastFileNameTid << fastName_ << "_pid" << std::setfill('0') << std::setw(5) << getpid() << "_tid" << i
284  << ".fast";
286  fastTid /= fastFileNameTid.str();
287  fastPathList_.push_back(fastTid.string());
288  }
289 
290  std::ostringstream moduleLegFile;
291  std::ostringstream moduleLegFileJson;
292  moduleLegFile << "microstatelegend_pid" << std::setfill('0') << std::setw(5) << getpid() << ".leg";
293  moduleLegFileJson << "microstatelegend_pid" << std::setfill('0') << std::setw(5) << getpid() << ".jsn";
294  moduleLegendFile_ = (workingDirectory_ / moduleLegFile.str()).string();
295  moduleLegendFileJson_ = (workingDirectory_ / moduleLegFileJson.str()).string();
296 
297  std::ostringstream pathLegFile;
298  std::ostringstream pathLegFileJson;
299  pathLegFile << "pathlegend_pid" << std::setfill('0') << std::setw(5) << getpid() << ".leg";
300  pathLegendFile_ = (workingDirectory_ / pathLegFile.str()).string();
301  pathLegFileJson << "pathlegend_pid" << std::setfill('0') << std::setw(5) << getpid() << ".jsn";
302  pathLegendFileJson_ = (workingDirectory_ / pathLegFileJson.str()).string();
303 
304  std::ostringstream inputLegFileJson;
305  inputLegFileJson << "inputlegend_pid" << std::setfill('0') << std::setw(5) << getpid() << ".jsn";
306  inputLegendFileJson_ = (workingDirectory_ / inputLegFileJson.str()).string();
307 
308  LogDebug("FastMonitoringService") << "Initializing FastMonitor with microstate def path -: " << microstateDefPath_;
309  //<< encPath_.current_ + 1 << " " << encModule_.current_ + 1
310 
311  /*
312  * initialize the fast monitor with:
313  * vector of pointers to monitorable parameters
314  * path to definition
315  *
316  */
317 
318  fmt_->m_data.macrostate_ = FastMonState::sInit;
319 
320  for (unsigned int i = 0; i < (FastMonState::mCOUNT); i++)
321  fmt_->m_data.encModule_.updateReserved(static_cast<const void*>(reservedMicroStateNames + i));
322  fmt_->m_data.encModule_.completeReservedWithDummies();
323 
324  for (unsigned int i = 0; i < nStreams_; i++) {
325  fmt_->m_data.ministate_.emplace_back(&nopath_);
326  fmt_->m_data.microstate_.emplace_back(&reservedMicroStateNames[FastMonState::mInvalid]);
327  fmt_->m_data.microstateAcqFlag_.push_back(0);
328 
329  //for synchronization
330  streamCounterUpdating_.push_back(new std::atomic<bool>(false));
331 
332  //path (mini) state
333  fmt_->m_data.encPath_.emplace_back(0);
334  fmt_->m_data.encPath_[i].update(static_cast<const void*>(&nopath_));
335 
336  for (auto& path : pathsInfo.paths()) {
337  fmt_->m_data.encPath_[i].updatePreinit(path);
338  }
339  for (auto& endPath : pathsInfo.endPaths()) {
340  fmt_->m_data.encPath_[i].updatePreinit(endPath);
341  }
342  }
343  //for (unsigned int i=0;i<nThreads_;i++)
344  // threadMicrostate_.push_back(&reservedMicroStateNames[mInvalid]);
345 
346  //initial size until we detect number of bins
347  fmt_->m_data.macrostateBins_ = FastMonState::MCOUNT;
348  fmt_->m_data.microstateBins_ = 0;
349  fmt_->m_data.inputstateBins_ = FastMonState::inCOUNT;
350  fmt_->m_data.ministateBins_ = fmt_->m_data.encPath_[0].vecsize();
351 
352  lastGlobalLumi_ = 0;
353  isInitTransition_ = true;
354  lumiFromSource_ = 0;
355 
356  //startup monitoring
357  fmt_->resetFastMonitor(microstateDefPath_, fastMicrostateDefPath_);
358  fmt_->jsonMonitor_->setNStreams(nStreams_);
359  fmt_->m_data.registerVariables(fmt_->jsonMonitor_.get(), nStreams_, threadIDAvailable_ ? nThreads_ : 0);
360  monInit_.store(false, std::memory_order_release);
361  if (sleepTime_ > 0)
363 
364  //this definition needs: #include "tbb/compat/thread"
365  //however this would results in TBB imeplementation replacing std::thread
366  //(both supposedly call pthread_self())
367  //number of threads created in process could be obtained from /proc,
368  //assuming that all posix threads are true kernel threads capable of running in parallel
369 
370  //#if TBB_IMPLEMENT_CPP0X
372  //threadIDAvailable_=true;
373  //#endif
374  }
std::atomic< bool > isInitTransition_
std::filesystem::path workingDirectory_
std::vector< std::atomic< bool > * > streamCounterUpdating_
static const edm::ModuleDescription reservedMicroStateNames[FastMonState::mCOUNT]
static const std::string nopath_
std::filesystem::path runDirectory_
std::vector< std::string > fastPathList_
std::shared_ptr< FastMonitoringThread > fmt_
Log< level::Warning, false > LogWarning
#define LogDebug(id)

◆ preEvent()

void evf::FastMonitoringService::preEvent ( edm::StreamContext const &  sc)

Definition at line 638 of file FastMonitoringService.cc.

Referenced by FastMonitoringService().

638 {}

◆ preGlobalBeginLumi()

void evf::FastMonitoringService::preGlobalBeginLumi ( edm::GlobalContext const &  gc)

Definition at line 495 of file FastMonitoringService.cc.

References fmt_, lastGlobalLumi_, CommonMethods::lock(), edm::LuminosityBlockID::luminosityBlock(), edm::GlobalContext::luminosityBlockID(), and lumiStartTime_.

Referenced by FastMonitoringService().

495  {
496  timeval lumiStartTime;
497  gettimeofday(&lumiStartTime, nullptr);
498  unsigned int newLumi = gc.luminosityBlockID().luminosityBlock();
499  lastGlobalLumi_ = newLumi;
500 
501  std::lock_guard<std::mutex> lock(fmt_->monlock_);
502  lumiStartTime_[newLumi] = lumiStartTime;
503  }
std::map< unsigned int, timeval > lumiStartTime_
std::shared_ptr< FastMonitoringThread > fmt_

◆ preGlobalEarlyTermination()

void evf::FastMonitoringService::preGlobalEarlyTermination ( edm::GlobalContext const &  gc,
edm::TerminationOrigin  to 
)

Definition at line 392 of file FastMonitoringService.cc.

References visDQMUpload::context, edm::ExceptionFromAnotherContext, edm::ExceptionFromThisContext, exceptionInLS_, edm::ExternalSignal, fmt_, has_data_exception_, CommonMethods::lock(), edm::LuminosityBlockID::luminosityBlock(), edm::GlobalContext::luminosityBlockID(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by FastMonitoringService().

392  {
395  context = " FromThisContext ";
397  context = " FromAnotherContext";
399  context = " FromExternalSignal";
400  edm::LogWarning("FastMonitoringService")
401  << " GLOBAL "
402  << "earlyTermination -: LS:" << gc.luminosityBlockID().luminosityBlock() << " " << context;
403  std::lock_guard<std::mutex> lock(fmt_->monlock_);
404  exceptionInLS_.push_back(gc.luminosityBlockID().luminosityBlock());
405  has_data_exception_.store(true);
406  }
std::atomic< bool > has_data_exception_
std::shared_ptr< FastMonitoringThread > fmt_
Log< level::Warning, false > LogWarning
std::vector< unsigned int > exceptionInLS_

◆ preGlobalEndLumi()

void evf::FastMonitoringService::preGlobalEndLumi ( edm::GlobalContext const &  gc)

Definition at line 505 of file FastMonitoringService.cc.

References accuSize_, daqInputSource_, doSnapshot(), Exception, exception_detected_, exceptionInLS_, filePerFwkStream_, fmt_, DAQSource::getEventReport(), FedRawDataInputSource::getEventReport(), inputSource_, CommonMethods::lock(), LogDebug, BXlumiParameters_cfi::lumi, edm::LuminosityBlockID::luminosityBlock(), edm::GlobalContext::luminosityBlockID(), lumiStartTime_, convertSQLitetoXML_cfg::output, castor_dqm_sourceclient_file_cfg::path, processedEventsPerLumi_, edm::shutdown_flag, sleepTime_, slowName_, throughputFactor(), jsoncollector::IntJ::value(), and workingDirectory_.

Referenced by FastMonitoringService().

505  {
506  unsigned int lumi = gc.luminosityBlockID().luminosityBlock();
507  LogDebug("FastMonitoringService") << "Lumi ended. Writing JSON information. LUMI -: " << lumi;
508  timeval lumiStopTime;
509  gettimeofday(&lumiStopTime, nullptr);
510 
511  std::lock_guard<std::mutex> lock(fmt_->monlock_);
512 
513  // Compute throughput
514  timeval stt = lumiStartTime_[lumi];
515  lumiStartTime_.erase(lumi);
516  unsigned long usecondsForLumi = (lumiStopTime.tv_sec - stt.tv_sec) * 1000000 + (lumiStopTime.tv_usec - stt.tv_usec);
517  unsigned long accuSize = accuSize_.find(lumi) == accuSize_.end() ? 0 : accuSize_[lumi];
518  accuSize_.erase(lumi);
519  double throughput = throughputFactor() * double(accuSize) / double(usecondsForLumi);
520  //store to registered variable
521  fmt_->m_data.fastThroughputJ_.value() = throughput;
522 
523  //update
524  doSnapshot(lumi, true);
525 
526  //retrieve one result we need (todo: sanity check if it's found)
527  IntJ* lumiProcessedJptr = dynamic_cast<IntJ*>(fmt_->jsonMonitor_->getMergedIntJForLumi("Processed", lumi));
528  if (!lumiProcessedJptr)
529  throw cms::Exception("FastMonitoringService") << "Internal error: got null pointer from FastMonitor";
530  processedEventsPerLumi_[lumi] = std::pair<unsigned int, bool>(lumiProcessedJptr->value(), false);
531 
532  //checking if exception has been thrown (in case of Global/Stream early termination, for this LS)
533  bool exception_detected = exception_detected_;
534  for (auto ex : exceptionInLS_)
535  if (lumi == ex)
536  exception_detected = true;
537 
538  if (edm::shutdown_flag || exception_detected) {
539  edm::LogInfo("FastMonitoringService")
540  << "Run interrupted. Skip writing EoL information -: " << processedEventsPerLumi_[lumi].first
541  << " events were processed in LUMI " << lumi;
542  //this will prevent output modules from producing json file for possibly incomplete lumi
543  processedEventsPerLumi_[lumi].first = 0;
544  processedEventsPerLumi_[lumi].second = true;
545  //disable this exception, so service can be used standalone (will be thrown if output module asks for this information)
546  //throw cms::Exception("FastMonitoringService") << "SOURCE did not send update for lumi block. LUMI -:" << lumi;
547  return;
548  }
549 
550  if (inputSource_ || daqInputSource_) {
551  auto sourceReport =
553  if (sourceReport.first) {
554  if (sourceReport.second != processedEventsPerLumi_[lumi].first) {
555  throw cms::Exception("FastMonitoringService") << "MISMATCH with SOURCE update. LUMI -: " << lumi
556  << ", events(processed):" << processedEventsPerLumi_[lumi].first
557  << " events(source):" << sourceReport.second;
558  }
559  }
560  }
561 
562  edm::LogInfo("FastMonitoringService")
563  << "Statistics for lumisection -: lumi = " << lumi << " events = " << lumiProcessedJptr->value()
564  << " time = " << usecondsForLumi / 1000000 << " size = " << accuSize << " thr = " << throughput;
565  delete lumiProcessedJptr;
566 
567  //full global and stream merge&output for this lumi
568 
569  // create file name for slow monitoring file
570  bool output = sleepTime_ > 0;
571  if (filePerFwkStream_) {
572  std::stringstream slowFileNameStem;
573  slowFileNameStem << slowName_ << "_ls" << std::setfill('0') << std::setw(4) << lumi << "_pid" << std::setfill('0')
574  << std::setw(5) << getpid();
576  slow /= slowFileNameStem.str();
577  fmt_->jsonMonitor_->outputFullJSONs(slow.string(), ".jsn", lumi, output);
578  } else {
579  std::stringstream slowFileName;
580  slowFileName << slowName_ << "_ls" << std::setfill('0') << std::setw(4) << lumi << "_pid" << std::setfill('0')
581  << std::setw(5) << getpid() << ".jsn";
583  slow /= slowFileName.str();
584  //full global and stream merge and JSON write for this lumi
585  fmt_->jsonMonitor_->outputFullJSON(slow.string(), lumi, output);
586  }
587  fmt_->jsonMonitor_->discardCollected(lumi); //we don't do further updates for this lumi
588  }
std::map< unsigned int, timeval > lumiStartTime_
std::pair< bool, unsigned int > getEventReport(unsigned int lumi, bool erase)
std::map< unsigned int, unsigned long > accuSize_
std::filesystem::path workingDirectory_
volatile std::atomic< bool > shutdown_flag
std::pair< bool, unsigned int > getEventReport(unsigned int lumi, bool erase)
Definition: DAQSource.cc:1378
std::map< unsigned int, std::pair< unsigned int, bool > > processedEventsPerLumi_
void doSnapshot(const unsigned int ls, const bool isGlobalEOL)
constexpr double throughputFactor()
Log< level::Info, false > LogInfo
FedRawDataInputSource * inputSource_
std::shared_ptr< FastMonitoringThread > fmt_
std::vector< unsigned int > exceptionInLS_
#define LogDebug(id)

◆ preModuleBeginJob()

void evf::FastMonitoringService::preModuleBeginJob ( edm::ModuleDescription const &  desc)

Definition at line 452 of file FastMonitoringService.cc.

References submitPVResolutionJobs::desc, fmt_, CommonMethods::lock(), and nOutputModules_.

Referenced by FastMonitoringService().

452  {
453  std::lock_guard<std::mutex> lock(fmt_->monlock_);
454  //std::cout << " Pre module Begin Job module: " << desc.moduleName() << std::endl;
455 
456  //build a map of modules keyed by their module description address
457  //here we need to treat output modules in a special way so they can be easily singled out
458  if (desc.moduleName() == "Stream" || desc.moduleName() == "GlobalEvFOutputModule" ||
459  desc.moduleName() == "EvFOutputModule" || desc.moduleName() == "EventStreamFileWriter" ||
460  desc.moduleName() == "PoolOutputModule") {
461  fmt_->m_data.encModule_.updateReserved((void*)&desc);
462  nOutputModules_++;
463  } else
464  fmt_->m_data.encModule_.update((void*)&desc);
465  }
std::shared_ptr< FastMonitoringThread > fmt_

◆ preModuleEvent()

void evf::FastMonitoringService::preModuleEvent ( edm::StreamContext const &  sc,
edm::ModuleCallingContext const &  mcc 
)

Definition at line 671 of file FastMonitoringService.cc.

References fmt_, edm::ModuleCallingContext::moduleDescription(), edm::StreamContext::streamID(), and edm::StreamID::value().

Referenced by FastMonitoringService().

671  {
672  fmt_->m_data.microstate_[sc.streamID().value()] = (void*)(mcc.moduleDescription());
673  fmt_->m_data.microstateAcqFlag_[sc.streamID().value()] = 0;
674  }
std::shared_ptr< FastMonitoringThread > fmt_

◆ preModuleEventAcquire()

void evf::FastMonitoringService::preModuleEventAcquire ( edm::StreamContext const &  sc,
edm::ModuleCallingContext const &  mcc 
)

Definition at line 660 of file FastMonitoringService.cc.

References fmt_, edm::ModuleCallingContext::moduleDescription(), edm::StreamContext::streamID(), and edm::StreamID::value().

Referenced by FastMonitoringService().

661  {
662  fmt_->m_data.microstate_[sc.streamID().value()] = (void*)(mcc.moduleDescription());
663  }
std::shared_ptr< FastMonitoringThread > fmt_

◆ prePathEvent()

void evf::FastMonitoringService::prePathEvent ( edm::StreamContext const &  sc,
edm::PathContext const &  pc 
)

Definition at line 634 of file FastMonitoringService.cc.

References fmt_, edm::PathContext::pathName(), and edm::StreamContext::streamID().

Referenced by FastMonitoringService().

634  {
635  fmt_->m_data.ministate_[sc.streamID()] = &(pc.pathName());
636  }
std::shared_ptr< FastMonitoringThread > fmt_

◆ preSourceEarlyTermination()

void evf::FastMonitoringService::preSourceEarlyTermination ( edm::TerminationOrigin  to)

Definition at line 408 of file FastMonitoringService.cc.

References visDQMUpload::context, exception_detected_, edm::ExceptionFromAnotherContext, edm::ExceptionFromThisContext, edm::ExternalSignal, fmt_, has_data_exception_, has_source_exception_, CommonMethods::lock(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by FastMonitoringService().

408  {
411  context = " FromThisContext ";
413  context = " FromAnotherContext";
415  context = " FromExternalSignal";
416  edm::LogWarning("FastMonitoringService") << " SOURCE "
417  << "earlyTermination -: " << context;
418  std::lock_guard<std::mutex> lock(fmt_->monlock_);
419  exception_detected_ = true;
420  has_source_exception_.store(true);
421  has_data_exception_.store(true);
422  }
std::atomic< bool > has_data_exception_
std::atomic< bool > has_source_exception_
std::shared_ptr< FastMonitoringThread > fmt_
Log< level::Warning, false > LogWarning

◆ preSourceEvent()

void evf::FastMonitoringService::preSourceEvent ( edm::StreamID  sid)

Definition at line 652 of file FastMonitoringService.cc.

References fmt_, evf::FastMonState::mInput, reservedMicroStateNames, and edm::StreamID::value().

Referenced by FastMonitoringService().

652  {
653  fmt_->m_data.microstate_[sid.value()] = &reservedMicroStateNames[FastMonState::mInput];
654  }
static const edm::ModuleDescription reservedMicroStateNames[FastMonState::mCOUNT]
unsigned int value() const
Definition: StreamID.h:43
std::shared_ptr< FastMonitoringThread > fmt_

◆ preStreamBeginLumi()

void evf::FastMonitoringService::preStreamBeginLumi ( edm::StreamContext const &  sc)

Definition at line 602 of file FastMonitoringService.cc.

References edm::StreamContext::eventID(), fmt_, CommonMethods::lock(), edm::EventID::luminosityBlock(), evf::FastMonState::mBoL, nopath_, reservedMicroStateNames, edm::StreamContext::streamID(), and edm::StreamID::value().

Referenced by FastMonitoringService().

602  {
603  unsigned int sid = sc.streamID().value();
604 
605  std::lock_guard<std::mutex> lock(fmt_->monlock_);
606  fmt_->m_data.streamLumi_[sid] = sc.eventID().luminosityBlock();
607 
608  //reset collected values for this stream
609  *(fmt_->m_data.processed_[sid]) = 0;
610 
611  fmt_->m_data.ministate_[sid] = &nopath_;
612  fmt_->m_data.microstate_[sid] = &reservedMicroStateNames[FastMonState::mBoL];
613  }
static const edm::ModuleDescription reservedMicroStateNames[FastMonState::mCOUNT]
static const std::string nopath_
std::shared_ptr< FastMonitoringThread > fmt_

◆ preStreamEarlyTermination()

void evf::FastMonitoringService::preStreamEarlyTermination ( edm::StreamContext const &  sc,
edm::TerminationOrigin  to 
)

Definition at line 376 of file FastMonitoringService.cc.

References visDQMUpload::context, edm::StreamContext::eventID(), edm::ExceptionFromAnotherContext, edm::ExceptionFromThisContext, exceptionInLS_, edm::ExternalSignal, fmt_, has_data_exception_, CommonMethods::lock(), edm::EventID::luminosityBlock(), edm::StreamContext::streamID(), AlCaHLTBitMon_QueryRunRegistry::string, and edm::StreamID::value().

Referenced by FastMonitoringService().

376  {
379  context = " FromThisContext ";
381  context = " FromAnotherContext";
383  context = " FromExternalSignal";
384  edm::LogWarning("FastMonitoringService")
385  << " STREAM " << sc.streamID().value() << " earlyTermination -: ID:" << sc.eventID()
386  << " LS:" << sc.eventID().luminosityBlock() << " " << context;
387  std::lock_guard<std::mutex> lock(fmt_->monlock_);
388  exceptionInLS_.push_back(sc.eventID().luminosityBlock());
389  has_data_exception_.store(true);
390  }
std::atomic< bool > has_data_exception_
std::shared_ptr< FastMonitoringThread > fmt_
Log< level::Warning, false > LogWarning
std::vector< unsigned int > exceptionInLS_

◆ preStreamEndLumi()

void evf::FastMonitoringService::preStreamEndLumi ( edm::StreamContext const &  sc)

Definition at line 619 of file FastMonitoringService.cc.

References edm::StreamContext::eventID(), fmt_, CommonMethods::lock(), edm::EventID::luminosityBlock(), evf::FastMonState::mEoL, nopath_, reservedMicroStateNames, edm::StreamContext::streamID(), and edm::StreamID::value().

Referenced by FastMonitoringService().

619  {
620  unsigned int sid = sc.streamID().value();
621  std::lock_guard<std::mutex> lock(fmt_->monlock_);
622 
623  //update processed count to be complete at this time
624  //doStreamEOLSnapshot(sc.eventID().luminosityBlock(), sid);
625  fmt_->jsonMonitor_->snapStreamAtomic(sc.eventID().luminosityBlock(), sid);
626  //reset this in case stream does not get notified of next lumi (we keep processed events only)
627  fmt_->m_data.ministate_[sid] = &nopath_;
628  fmt_->m_data.microstate_[sid] = &reservedMicroStateNames[FastMonState::mEoL];
629  }
static const edm::ModuleDescription reservedMicroStateNames[FastMonState::mCOUNT]
static const std::string nopath_
std::shared_ptr< FastMonitoringThread > fmt_

◆ reportLockWait()

void evf::FastMonitoringService::reportLockWait ( unsigned int  ls,
double  waitTime,
unsigned int  lockCount 
)

Definition at line 745 of file FastMonitoringService.cc.

References fmt_, CommonMethods::lock(), lockStatsDuringLumi_, and eostools::ls().

Referenced by FedRawDataInputSource::readSupervisor(), and DAQSource::readSupervisor().

745  {
746  std::lock_guard<std::mutex> lock(fmt_->monlock_);
747  lockStatsDuringLumi_[ls] = std::pair<double, unsigned int>(waitTime, lockCount);
748  }
def ls(path, rec=False)
Definition: eostools.py:349
std::map< unsigned int, std::pair< double, unsigned int > > lockStatsDuringLumi_
std::shared_ptr< FastMonitoringThread > fmt_

◆ setExceptionDetected()

void evf::FastMonitoringService::setExceptionDetected ( unsigned int  ls)

Definition at line 424 of file FastMonitoringService.cc.

References exception_detected_, exceptionInLS_, fmt_, CommonMethods::lock(), and eostools::ls().

Referenced by FedRawDataInputSource::getNextEvent(), and DAQSource::getNextEventFromDataBlock().

424  {
425  std::lock_guard<std::mutex> lock(fmt_->monlock_);
426  if (!ls)
427  exception_detected_ = true;
428  else
429  exceptionInLS_.push_back(ls);
430  }
def ls(path, rec=False)
Definition: eostools.py:349
std::shared_ptr< FastMonitoringThread > fmt_
std::vector< unsigned int > exceptionInLS_

◆ setInputSource() [1/2]

void evf::FastMonitoringService::setInputSource ( FedRawDataInputSource inputSource)
inline

Definition at line 222 of file FastMonitoringService.h.

References inputSource_.

Referenced by DAQSource::DAQSource(), and FedRawDataInputSource::FedRawDataInputSource().

222 { inputSource_ = inputSource; }
FedRawDataInputSource * inputSource_

◆ setInputSource() [2/2]

void evf::FastMonitoringService::setInputSource ( DAQSource inputSource)
inline

Definition at line 223 of file FastMonitoringService.h.

References daqInputSource_.

223 { daqInputSource_ = inputSource; }

◆ setInState()

void evf::FastMonitoringService::setInState ( FastMonState::InputState  inputState)
inline

◆ setInStateSup()

void evf::FastMonitoringService::setInStateSup ( FastMonState::InputState  inputState)
inline

◆ setMicroState() [1/2]

void evf::FastMonitoringService::setMicroState ( FastMonState::Microstate  m)

Definition at line 684 of file FastMonitoringService.cc.

References fmt_, mps_fire::i, visualization-live-secondInstance_cfg::m, nStreams_, and reservedMicroStateNames.

684  {
685  for (unsigned int i = 0; i < nStreams_; i++)
686  fmt_->m_data.microstate_[i] = &reservedMicroStateNames[m];
687  }
static const edm::ModuleDescription reservedMicroStateNames[FastMonState::mCOUNT]
std::shared_ptr< FastMonitoringThread > fmt_

◆ setMicroState() [2/2]

void evf::FastMonitoringService::setMicroState ( edm::StreamID  sid,
FastMonState::Microstate  m 
)

Definition at line 690 of file FastMonitoringService.cc.

References fmt_, visualization-live-secondInstance_cfg::m, and reservedMicroStateNames.

690  {
691  fmt_->m_data.microstate_[sid] = &reservedMicroStateNames[m];
692  }
static const edm::ModuleDescription reservedMicroStateNames[FastMonState::mCOUNT]
std::shared_ptr< FastMonitoringThread > fmt_

◆ shouldWriteFiles()

bool evf::FastMonitoringService::shouldWriteFiles ( unsigned int  lumi,
unsigned int *  proc = nullptr 
)
inline

Definition at line 215 of file FastMonitoringService.h.

References getAbortFlagForLumi(), getEventsProcessedForLumi(), and ValidateTausOnZEEFastSim_cff::proc.

Referenced by L1TriggerJSONMonitoring::globalEndLuminosityBlockSummary(), and HLTriggerJSONMonitoring::globalEndLuminosityBlockSummary().

215  {
216  unsigned int processed = getEventsProcessedForLumi(lumi);
217  if (proc)
218  *proc = processed;
219  return !getAbortFlagForLumi(lumi);
220  }
unsigned int getEventsProcessedForLumi(unsigned int lumi, bool *abortFlag=nullptr)
bool getAbortFlagForLumi(unsigned int lumi)

◆ snapshotRunner()

void evf::FastMonitoringService::snapshotRunner ( )
private

Definition at line 785 of file FastMonitoringService.cc.

References doSnapshot(), relativeConstraints::empty, f, fastMonIntervals_, fastPath_, fastPathList_, filePerFwkStream_, fmt_, mps_fire::i, inputState_, inputStateNames, inputSupervisorState_, lastGlobalLumi_, CommonMethods::lock(), monInit_, mps_check::msg, nStreams_, AlCaHLTBitMon_ParallelJobs::p, sleepTime_, snapCounter_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by preBeginJob().

785  {
786  monInit_.exchange(true, std::memory_order_acquire);
787  while (!fmt_->m_stoprequest) {
788  std::vector<std::vector<unsigned int>> lastEnc;
789  {
790  std::unique_lock<std::mutex> lock(fmt_->monlock_);
791 
792  doSnapshot(lastGlobalLumi_, false);
793 
794  lastEnc.emplace_back(fmt_->m_data.ministateEncoded_);
795  lastEnc.emplace_back(fmt_->m_data.microstateEncoded_);
796 
798  if (filePerFwkStream_) {
799  std::vector<std::string> CSVv;
800  for (unsigned int i = 0; i < nStreams_; i++) {
801  CSVv.push_back(fmt_->jsonMonitor_->getCSVString((int)i));
802  }
803  // release mutex before writing out fast path file
804  lock.release()->unlock();
805  for (unsigned int i = 0; i < nStreams_; i++) {
806  if (!CSVv[i].empty())
807  fmt_->jsonMonitor_->outputCSV(fastPathList_[i], CSVv[i]);
808  }
809  } else {
810  std::string CSV = fmt_->jsonMonitor_->getCSVString();
811  // release mutex before writing out fast path file
812  lock.release()->unlock();
813  if (!CSV.empty())
814  fmt_->jsonMonitor_->outputCSV(fastPath_, CSV);
815  }
816  }
817  snapCounter_++;
818  }
819 
820  {
821  edm::LogInfo msg("FastMonitoringService");
822  auto f = [&](std::vector<unsigned int> const& p) {
823  for (unsigned int i = 0; i < nStreams_; i++) {
824  if (i == 0)
825  msg << "[" << p[i] << ",";
826  else if (i <= nStreams_ - 1)
827  msg << p[i] << ",";
828  else
829  msg << p[i] << "]";
830  }
831  };
832 
833  msg << "Current states: Ms=" << fmt_->m_data.fastMacrostateJ_.value() << " ms=";
834  f(lastEnc[0]);
835  msg << " us=";
836  f(lastEnc[1]);
838  }
839 
840  ::sleep(sleepTime_);
841  }
842  }
std::atomic< FastMonState::InputState > inputState_
static const std::string inputStateNames[FastMonState::inCOUNT]
void doSnapshot(const unsigned int ls, const bool isGlobalEOL)
std::atomic< FastMonState::InputState > inputSupervisorState_
double f[11][100]
std::vector< std::string > fastPathList_
tuple msg
Definition: mps_check.py:286
std::shared_ptr< FastMonitoringThread > fmt_

◆ startedLookingForFile()

void evf::FastMonitoringService::startedLookingForFile ( )

Definition at line 709 of file FastMonitoringService.cc.

References fileLookStart_.

Referenced by FedRawDataInputSource::readSupervisor(), and DAQSource::readSupervisor().

709  {
710  gettimeofday(&fileLookStart_, nullptr);
711  /*
712  std::cout << "Started looking for .raw file at: s=" << fileLookStart_.tv_sec << ": ms = "
713  << fileLookStart_.tv_usec / 1000.0 << std::endl;
714  */
715  }

◆ stoppedLookingForFile()

void evf::FastMonitoringService::stoppedLookingForFile ( unsigned int  lumi)

Definition at line 717 of file FastMonitoringService.cc.

References avgLeadTime_, fileLookStart_, fileLookStop_, fmt_, mps_fire::i, leadTimes_, CommonMethods::lock(), BXlumiParameters_cfi::lumi, and lumiFromSource_.

Referenced by FedRawDataInputSource::readSupervisor(), and DAQSource::readSupervisor().

717  {
718  gettimeofday(&fileLookStop_, nullptr);
719  /*
720  std::cout << "Stopped looking for .raw file at: s=" << fileLookStop_.tv_sec << ": ms = "
721  << fileLookStop_.tv_usec / 1000.0 << std::endl;
722  */
723  std::lock_guard<std::mutex> lock(fmt_->monlock_);
724 
725  if (lumi > lumiFromSource_) {
727  leadTimes_.clear();
728  }
729  unsigned long elapsedTime = (fileLookStop_.tv_sec - fileLookStart_.tv_sec) * 1000000 // sec to us
730  + (fileLookStop_.tv_usec - fileLookStart_.tv_usec); // us
731  // add this to lead times for this lumi
732  leadTimes_.push_back((double)elapsedTime);
733 
734  // recompute average lead time for this lumi
735  if (leadTimes_.size() == 1)
737  else {
738  double totTime = 0;
739  for (unsigned int i = 0; i < leadTimes_.size(); i++)
740  totTime += leadTimes_[i];
741  avgLeadTime_[lumi] = 0.001 * (totTime / leadTimes_.size());
742  }
743  }
std::map< unsigned int, double > avgLeadTime_
std::vector< double > leadTimes_
std::shared_ptr< FastMonitoringThread > fmt_

Member Data Documentation

◆ accuSize_

std::map<unsigned int, unsigned long> evf::FastMonitoringService::accuSize_
private

Definition at line 264 of file FastMonitoringService.h.

Referenced by accumulateFileSize(), and preGlobalEndLumi().

◆ avgLeadTime_

std::map<unsigned int, double> evf::FastMonitoringService::avgLeadTime_
private

Definition at line 261 of file FastMonitoringService.h.

Referenced by doSnapshot(), postGlobalEndLumi(), and stoppedLookingForFile().

◆ collectedPathList_

std::vector<std::atomic<bool>*> evf::FastMonitoringService::collectedPathList_
private

Definition at line 275 of file FastMonitoringService.h.

◆ daqInputSource_

DAQSource* evf::FastMonitoringService::daqInputSource_ = nullptr
private

Definition at line 237 of file FastMonitoringService.h.

Referenced by preGlobalEndLumi(), and setInputSource().

◆ exception_detected_

bool evf::FastMonitoringService::exception_detected_ = false
private

◆ exceptionInLS_

std::vector<unsigned int> evf::FastMonitoringService::exceptionInLS_
private

◆ fastMicrostateDefPath_

std::string evf::FastMonitoringService::fastMicrostateDefPath_
private

Definition at line 246 of file FastMonitoringService.h.

Referenced by FastMonitoringService(), and preBeginJob().

◆ fastMonIntervals_

unsigned int evf::FastMonitoringService::fastMonIntervals_
private

Definition at line 244 of file FastMonitoringService.h.

Referenced by snapshotRunner().

◆ fastName_

std::string evf::FastMonitoringService::fastName_
private

Definition at line 247 of file FastMonitoringService.h.

Referenced by preBeginJob().

◆ fastPath_

std::string evf::FastMonitoringService::fastPath_
private

Definition at line 247 of file FastMonitoringService.h.

Referenced by preBeginJob(), and snapshotRunner().

◆ fastPathList_

std::vector<std::string> evf::FastMonitoringService::fastPathList_
private

Definition at line 296 of file FastMonitoringService.h.

Referenced by preBeginJob(), and snapshotRunner().

◆ fileLookStart_

timeval evf::FastMonitoringService::fileLookStart_
private

Definition at line 253 of file FastMonitoringService.h.

Referenced by startedLookingForFile(), and stoppedLookingForFile().

◆ fileLookStop_

timeval evf::FastMonitoringService::fileLookStop_
private

Definition at line 253 of file FastMonitoringService.h.

Referenced by stoppedLookingForFile().

◆ filePerFwkStream_

bool evf::FastMonitoringService::filePerFwkStream_
private

Definition at line 248 of file FastMonitoringService.h.

Referenced by preBeginJob(), preGlobalEndLumi(), and snapshotRunner().

◆ filesProcessedDuringLumi_

std::map<unsigned int, unsigned int> evf::FastMonitoringService::filesProcessedDuringLumi_
private

Definition at line 262 of file FastMonitoringService.h.

Referenced by accumulateFileSize(), doSnapshot(), and postGlobalEndLumi().

◆ fmt_

std::shared_ptr<FastMonitoringThread> evf::FastMonitoringService::fmt_
private

◆ has_data_exception_

std::atomic<bool> evf::FastMonitoringService::has_data_exception_ = false
private

◆ has_source_exception_

std::atomic<bool> evf::FastMonitoringService::has_source_exception_ = false
private

◆ inputLegendFileJson_

std::string evf::FastMonitoringService::inputLegendFileJson_
private

Definition at line 288 of file FastMonitoringService.h.

Referenced by postBeginJob(), and preBeginJob().

◆ inputSource_

FedRawDataInputSource* evf::FastMonitoringService::inputSource_ = nullptr
private

Definition at line 236 of file FastMonitoringService.h.

Referenced by preGlobalEndLumi(), and setInputSource().

◆ inputState_

std::atomic<FastMonState::InputState> evf::FastMonitoringService::inputState_ {FastMonState::InputState::inInit}
private

Definition at line 238 of file FastMonitoringService.h.

Referenced by doSnapshot(), setInState(), and snapshotRunner().

◆ inputStateNames

const std::string evf::FastMonitoringService::inputStateNames
static

Definition at line 161 of file FastMonitoringService.h.

Referenced by makeInputLegendaJson(), and snapshotRunner().

◆ inputSupervisorState_

std::atomic<FastMonState::InputState> evf::FastMonitoringService::inputSupervisorState_ {FastMonState::InputState::inInit}
private

Definition at line 239 of file FastMonitoringService.h.

Referenced by doSnapshot(), setInStateSup(), and snapshotRunner().

◆ isInitTransition_

std::atomic<bool> evf::FastMonitoringService::isInitTransition_
private

Definition at line 256 of file FastMonitoringService.h.

Referenced by doSnapshot(), postGlobalBeginRun(), and preBeginJob().

◆ lastGlobalLumi_

unsigned int evf::FastMonitoringService::lastGlobalLumi_
private

Definition at line 255 of file FastMonitoringService.h.

Referenced by preBeginJob(), preGlobalBeginLumi(), and snapshotRunner().

◆ leadTimes_

std::vector<double> evf::FastMonitoringService::leadTimes_
private

Definition at line 265 of file FastMonitoringService.h.

Referenced by stoppedLookingForFile().

◆ lockStatsDuringLumi_

std::map<unsigned int, std::pair<double, unsigned int> > evf::FastMonitoringService::lockStatsDuringLumi_
private

Definition at line 266 of file FastMonitoringService.h.

Referenced by doSnapshot(), postGlobalEndLumi(), and reportLockWait().

◆ lumiFromSource_

unsigned int evf::FastMonitoringService::lumiFromSource_
private

Definition at line 257 of file FastMonitoringService.h.

Referenced by preBeginJob(), and stoppedLookingForFile().

◆ lumiStartTime_

std::map<unsigned int, timeval> evf::FastMonitoringService::lumiStartTime_
private

Definition at line 252 of file FastMonitoringService.h.

Referenced by preGlobalBeginLumi(), and preGlobalEndLumi().

◆ macroStateNames

const std::string evf::FastMonitoringService::macroStateNames
static
Initial value:
= {"Init",
"JobReady",
"RunGiven",
"Running",
"Stopping",
"Done",
"JobEnded",
"Error",
"ErrorEnded",
"End",
"Invalid"}

Definition at line 160 of file FastMonitoringService.h.

◆ microstateDefPath_

std::string evf::FastMonitoringService::microstateDefPath_
private

Definition at line 246 of file FastMonitoringService.h.

Referenced by FastMonitoringService(), and preBeginJob().

◆ moduleLegendFile_

std::string evf::FastMonitoringService::moduleLegendFile_
private

Definition at line 284 of file FastMonitoringService.h.

Referenced by preBeginJob().

◆ moduleLegendFileJson_

std::string evf::FastMonitoringService::moduleLegendFileJson_
private

Definition at line 285 of file FastMonitoringService.h.

Referenced by postBeginJob(), and preBeginJob().

◆ monInit_

std::atomic<bool> evf::FastMonitoringService::monInit_
private

Definition at line 291 of file FastMonitoringService.h.

Referenced by preBeginJob(), and snapshotRunner().

◆ nopath_

const std::string evf::FastMonitoringService::nopath_ = "NoPath"
static

◆ nOutputModules_

unsigned int evf::FastMonitoringService::nOutputModules_ = 0
private

Definition at line 289 of file FastMonitoringService.h.

Referenced by makeModuleLegendaJson(), and preModuleBeginJob().

◆ nStreams_

unsigned int evf::FastMonitoringService::nStreams_
private

◆ nThreads_

unsigned int evf::FastMonitoringService::nThreads_
private

Definition at line 242 of file FastMonitoringService.h.

Referenced by preallocate(), and preBeginJob().

◆ pathLegendFile_

std::string evf::FastMonitoringService::pathLegendFile_
private

Definition at line 286 of file FastMonitoringService.h.

Referenced by preBeginJob().

◆ pathLegendFileJson_

std::string evf::FastMonitoringService::pathLegendFileJson_
private

Definition at line 287 of file FastMonitoringService.h.

Referenced by postBeginJob(), and preBeginJob().

◆ pathNamesReady_

std::vector<bool> evf::FastMonitoringService::pathNamesReady_
private

Definition at line 276 of file FastMonitoringService.h.

◆ processedEventsPerLumi_

std::map<unsigned int, std::pair<unsigned int, bool> > evf::FastMonitoringService::processedEventsPerLumi_
private

◆ reservedMicroStateNames

const edm::ModuleDescription evf::FastMonitoringService::reservedMicroStateNames
static
Initial value:
= {
edm::ModuleDescription("Dummy", "Invalid"),
edm::ModuleDescription("Dummy", "Idle"),
edm::ModuleDescription("Dummy", "FwkOvhSrc"),
edm::ModuleDescription("Dummy", "FwkOvhMod"),
edm::ModuleDescription("Dummy", "FwkEoL"),
edm::ModuleDescription("Dummy", "Input"),
edm::ModuleDescription("Dummy", "DQM"),
edm::ModuleDescription("Dummy", "BoL"),
edm::ModuleDescription("Dummy", "EoL"),
edm::ModuleDescription("Dummy", "GlobalEoL")}

Definition at line 159 of file FastMonitoringService.h.

Referenced by doSnapshot(), postEvent(), postModuleEvent(), postSourceEvent(), postStreamBeginLumi(), postStreamEndLumi(), preBeginJob(), preSourceEvent(), preStreamBeginLumi(), preStreamEndLumi(), and setMicroState().

◆ runDirectory_

std::filesystem::path evf::FastMonitoringService::runDirectory_
private

Definition at line 278 of file FastMonitoringService.h.

Referenced by getRunDirName(), and preBeginJob().

◆ sleepTime_

int evf::FastMonitoringService::sleepTime_
private

Definition at line 243 of file FastMonitoringService.h.

Referenced by preBeginJob(), preGlobalEndLumi(), and snapshotRunner().

◆ slowName_

std::string evf::FastMonitoringService::slowName_
private

Definition at line 247 of file FastMonitoringService.h.

Referenced by preGlobalEndLumi().

◆ snapCounter_

unsigned int evf::FastMonitoringService::snapCounter_ = 0
private

Definition at line 245 of file FastMonitoringService.h.

Referenced by snapshotRunner().

◆ streamCounterUpdating_

std::vector<std::atomic<bool>*> evf::FastMonitoringService::streamCounterUpdating_
private

Definition at line 273 of file FastMonitoringService.h.

Referenced by preBeginJob().

◆ threadIDAvailable_

bool evf::FastMonitoringService::threadIDAvailable_ = false
private

Definition at line 280 of file FastMonitoringService.h.

Referenced by preBeginJob().

◆ totalEventsProcessed_

std::atomic<unsigned long> evf::FastMonitoringService::totalEventsProcessed_
private

Definition at line 282 of file FastMonitoringService.h.

Referenced by postEvent().

◆ workingDirectory_

std::filesystem::path evf::FastMonitoringService::workingDirectory_
private

Definition at line 278 of file FastMonitoringService.h.

Referenced by preBeginJob(), and preGlobalEndLumi().