CMS 3D CMS Logo

JobReport.h
Go to the documentation of this file.
1 #ifndef FWCore_MessageLogger_JobReport_h
2 #define FWCore_MessageLogger_JobReport_h
3 // -*- C++ -*-
4 //
5 // Package: MessageLogger
6 // Class : JobReport
7 //
74 //
75 // Original Author: Marc Paterno
76 //
77 
78 /*
79 Changes Log 1: 2009/01/14 10:29:00, Natalia Garcia Nebot
80  Modified and added some methods to report CPU and memory information from /proc/cpuinfo
81  and /proc/meminfo files and Memory statistics
82 */
83 
87 
88 #include <atomic>
89 #include <cstddef>
90 #include <iosfwd>
91 #include <map>
92 #include <memory>
93 #include <mutex>
94 #include <set>
95 #include <string>
96 #include <vector>
97 
98 #include "tbb/concurrent_unordered_map.h"
99 #include "tbb/concurrent_vector.h"
100 
101 namespace edm {
102 
103  class JobReport {
104  public:
105  typedef unsigned int RunNumber;
106  typedef std::size_t Token;
107 
108  struct RunReport {
110  std::map<unsigned int, unsigned long> lumiSectionsToNEvents;
111  };
112 
122  struct InputFile {
123  typedef std::vector<std::string> StringVector;
124 
128  std::string inputType; // primaryFiles, secondaryFiles, mixingFiles
129  std::string inputSourceClassName; // class which created the file
130  std::string moduleLabel; // name of class instance
132  std::size_t numEventsRead;
134  std::map<RunNumber, RunReport> runReports;
136  std::set<std::string> fastClonedBranches;
137  };
138 
148  struct OutputFile {
150 
155  std::string moduleLabel; // name of class instance
159  std::size_t numEventsWritten;
161  std::vector<Token> contributingInputs;
162  tbb::concurrent_vector<Token> contributingInputsSecSource;
163  std::map<std::string, bool> fastCopyingInputs;
164  std::map<RunNumber, RunReport> runReports;
166  };
167 
169  public:
172  std::atomic<long long>& value() { return value_; }
173  std::atomic<long long> const& value() const { return value_; }
174 
175  private:
176  std::atomic<long long> value_;
177  };
178 
179  struct JobReportImpl {
180  JobReportImpl& operator=(JobReportImpl const&) = delete;
181  JobReportImpl(JobReportImpl const&) = delete;
182 
185 
186  /*
187  * Add the input file token provided to every output
188  * file currently available.
189  * Used whenever a new input file is opened, it's token
190  * is added to all open output files as a contributor
191  */
192  void insertInputForOutputs(InputType inputType, Token t);
193 
194  /*
195  * Associate a Lumi Section to all open output files
196  *
197  */
199  unsigned int runNumber,
200  unsigned int lumiSection,
201  unsigned long nEvents);
202 
203  /*
204  * Associate a Lumi Section to all open input files
205  *
206  */
207  void associateInputLumiSection(unsigned int runNumber, unsigned int lumiSection);
208 
209  /*
210  * Associate a run to all open output files
211  */
212  void associateRun(JobReport::Token token, unsigned int runNumber);
213 
214  /*
215  * Associate a run to all open output files
216  */
217  void associateInputRun(unsigned int runNumber);
218 
219  /*
220  * Write an InputFile object to the Logger
221  * Generate XML string for InputFile instance and dispatch to
222  * job report via MessageLogger
223  */
224  void writeInputFile(InputFile const& f);
225 
226  /*
227  * Write an OutputFile object to the Logger
228  * Generate an XML string for the OutputFile provided and
229  * dispatch it to the logger
230  * Contributing input tokens are resolved to the input LFN and PFN
231  *
232  * TODO: We have not yet addressed the issue where we cleanup not
233  * contributing input files.
234  * Also, it is possible to get fake input to output file mappings
235  * if an input file is open already when a new output file is opened
236  * but the input gets closed without contributing events to the
237  * output file due to filtering etc.
238  *
239  */
240  void writeOutputFile(OutputFile const& f);
241 
242  /*
243  * Flush all open files to logger in event of a problem.
244  */
245  void flushFiles(void);
246 
247  JobReportImpl(std::ostream* iOst) : printedReadBranches_(false), ost_(iOst) {}
248 
249  std::ostream const* ost() const { return get_underlying_safe(ost_); }
250  std::ostream*& ost() { return get_underlying_safe(ost_); }
251 
252  std::vector<InputFile> inputFiles_;
253  tbb::concurrent_vector<InputFile> inputFilesSecSource_;
254  tbb::concurrent_vector<OutputFile> outputFiles_;
255  std::map<std::string, long long> readBranches_;
256  std::map<std::string, long long> readBranchesSecFile_;
257  tbb::concurrent_unordered_map<std::string, AtomicLongLong> readBranchesSecSource_;
261  };
262 
263  JobReport();
264  //Does not take ownership of pointer
265  JobReport(std::ostream* outputStream);
266 
267  JobReport& operator=(JobReport const&) = delete;
268  JobReport(JobReport const&) = delete;
269 
270  ~JobReport();
271 
275  Token inputFileOpened(std::string const& physicalFileName,
276  std::string const& logicalFileName,
277  std::string const& catalog,
278  std::string const& inputType,
279  std::string const& inputSourceClassName,
280  std::string const& moduleLabel,
281  std::string const& guid,
282  std::vector<std::string> const& branchNames);
283 
286  void eventReadFromFile(InputType inputType, Token fileToken);
287 
292  // CMS-THREADING Current implementation requires an instance of an
293  // OuputModule run on only one thread at a time.
294  void reportDataType(Token fileToken, std::string const& dataType);
295 
299  void inputFileClosed(InputType inputType, Token fileToken);
300 
304  Token outputFileOpened(std::string const& physicalFileName,
305  std::string const& logicalFileName,
306  std::string const& catalog,
307  std::string const& outputModuleClassName,
308  std::string const& moduleLabel,
309  std::string const& guid,
310  std::string const& dataType,
311  std::string const& branchHash,
312  std::vector<std::string> const& branchNames);
313 
316  // CMS-THREADING Current implementation requires an instance of an
317  // OuputModule run on only one thread at a time.
319 
323  void outputFileClosed(Token fileToken);
324 
326 
331  void reportRunNumber(JobReport::Token token, unsigned int run);
332 
337  void reportLumiSection(JobReport::Token token, unsigned int run, unsigned int lumiSectId, unsigned long nEvents = 0);
338 
344  void reportInputLumiSection(unsigned int run, unsigned int lumiSectId);
345 
349  void reportInputRunNumber(unsigned int run);
350 
356  void reportError(std::string const& shortDesc, std::string const& longDesc, int const& exitCode);
357 
363  void reportSkippedFile(std::string const& pfn, std::string const& lfn);
364 
365  void reportFallbackAttempt(std::string const& pfn, std::string const& lfn, std::string const& err);
366 
367  void reportAnalysisFile(std::string const& fileName, std::map<std::string, std::string> const& fileData);
368 
375  void reportMemoryInfo(std::vector<std::string> const& memoryData);
376 
383  void reportMessageInfo(std::map<std::string, double> const& messageData);
384 
391  void reportReadBranches();
392 
394  void reportReadBranch(InputType inputType, std::string const& branchName);
395 
397  void reportFastClonedBranches(std::set<std::string> const& fastClonedBranches, long long nEvents);
398 
403 
404  /*
405  * Report information about fast copying. Called for each open output file
406  * whenever an input file is opened.
407  */
408  void reportFastCopyingStatus(Token t, std::string const& inputFileName, bool fastCopying);
409 
417  void reportPerformanceSummary(std::string const& metricClass, std::map<std::string, std::string> const& metrics);
418 
419  void reportPerformanceForModule(std::string const& metricClass,
420  std::string const& moduleName,
421  std::map<std::string, std::string> const& metrics);
422 
424  std::string dumpFiles(void);
425 
426  protected:
428 
429  private:
432  };
433 
434  std::ostream& operator<<(std::ostream& os, JobReport::InputFile const& f);
435  std::ostream& operator<<(std::ostream& os, JobReport::OutputFile const& f);
436 } // namespace edm
437 #endif
edm::JobReport::JobReportImpl::operator=
JobReportImpl & operator=(JobReportImpl const &)=delete
edm::JobReport::JobReportImpl::ost_
edm::propagate_const< std::ostream * > ost_
Definition: JobReport.h:260
edm::JobReport::AtomicLongLong::AtomicLongLong
AtomicLongLong(AtomicLongLong const &r)
Definition: JobReport.h:171
edm::RunNumber_t
unsigned int RunNumber_t
Definition: RunLumiEventNumber.h:14
edm::JobReport::OutputFile::runReports
std::map< RunNumber, RunReport > runReports
Definition: JobReport.h:164
edm::JobReport::InputFile
Definition: JobReport.h:122
edm::JobReport::JobReportImpl::associateInputRun
void associateInputRun(unsigned int runNumber)
Definition: JobReport.cc:263
edm::JobReport::OutputFile::fileHasBeenClosed
bool fileHasBeenClosed
Definition: JobReport.h:165
funct::false
false
Definition: Factorize.h:29
edm::JobReport::reportFastClonedBranches
void reportFastClonedBranches(std::set< std::string > const &fastClonedBranches, long long nEvents)
Inform the job report that branches have been fast Cloned.
Definition: JobReport.cc:626
getEcalConditions_orcoffint2r_cff.catalog
catalog
Definition: getEcalConditions_orcoffint2r_cff.py:40
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
edm::JobReport::dumpFiles
std::string dumpFiles(void)
debug/test util
Definition: JobReport.cc:692
edm::JobReport::reportInputLumiSection
void reportInputLumiSection(unsigned int run, unsigned int lumiSectId)
Definition: JobReport.cc:465
edm::JobReport::RunNumber
unsigned int RunNumber
Definition: JobReport.h:105
electrons_cff.branchName
branchName
Definition: electrons_cff.py:521
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::JobReport::JobReportImpl::ost
std::ostream const * ost() const
Definition: JobReport.h:249
edm::JobReport::JobReportImpl::inputFilesSecSource_
tbb::concurrent_vector< InputFile > inputFilesSecSource_
Definition: JobReport.h:253
edm::JobReport::Token
std::size_t Token
Definition: JobReport.h:106
RunLumiEventNumber.h
edm::JobReport::reportAnalysisFile
void reportAnalysisFile(std::string const &fileName, std::map< std::string, std::string > const &fileData)
Definition: JobReport.cc:473
edm::JobReport::OutputFile::catalog
std::string catalog
Definition: JobReport.h:153
edm::JobReport::reportReadBranch
void reportReadBranch(InputType inputType, std::string const &branchName)
Inform the job report that a branch has been read.
Definition: JobReport.cc:611
edm::moduleName
std::string moduleName(StableProvenance const &provenance, ProcessHistory const &history)
Definition: Provenance.cc:27
edm::JobReport::AtomicLongLong::value_
std::atomic< long long > value_
Definition: JobReport.h:176
edm::JobReport::OutputFile::logicalFileName
std::string logicalFileName
Definition: JobReport.h:151
edm::JobReport::JobReportImpl::associateLumiSection
void associateLumiSection(JobReport::Token token, unsigned int runNumber, unsigned int lumiSection, unsigned long nEvents)
Definition: JobReport.cc:275
edm::JobReport::InputFile::branchNames
StringVector branchNames
Definition: JobReport.h:133
edm::JobReport::RunReport
Definition: JobReport.h:108
edm::JobReport::eventWrittenToFile
void eventWrittenToFile(Token fileToken, RunNumber_t run, EventNumber_t event)
Definition: JobReport.cc:428
edm::JobReport::InputFile::runReports
std::map< RunNumber, RunReport > runReports
Definition: JobReport.h:134
edm::get_underlying_safe
constexpr std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
Definition: get_underlying_safe.h:41
edm::JobReport::reportDataType
void reportDataType(Token fileToken, std::string const &dataType)
Definition: JobReport.cc:371
edm::JobReport::JobReportImpl::lastOpenedPrimaryInputFile_
std::vector< InputFile >::size_type lastOpenedPrimaryInputFile_
Definition: JobReport.h:259
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
edm::JobReport::AtomicLongLong::value
std::atomic< long long > const & value() const
Definition: JobReport.h:173
edm::JobReport::AtomicLongLong
Definition: JobReport.h:168
DTskim_cfg.dataType
dataType
Definition: DTskim_cfg.py:56
edm::JobReport::OutputFile::branchNames
StringVector branchNames
Definition: JobReport.h:160
edm::JobReport::inputFileClosed
void inputFileClosed(InputType inputType, Token fileToken)
Definition: JobReport.cc:376
edm::InputType
InputType
Definition: InputType.h:5
edm::JobReport::JobReportImpl::writeOutputFile
void writeOutputFile(OutputFile const &f)
Definition: JobReport.cc:195
edm::JobReport::OutputFile::moduleLabel
std::string moduleLabel
Definition: JobReport.h:155
edm::JobReport::JobReportImpl::JobReportImpl
JobReportImpl(std::ostream *iOst)
Definition: JobReport.h:247
convertSQLiteXML.runNumber
runNumber
Definition: convertSQLiteXML.py:91
edm::JobReport::OutputFile::outputModuleClassName
std::string outputModuleClassName
Definition: JobReport.h:154
edm::JobReport::JobReportImpl::outputFiles_
tbb::concurrent_vector< OutputFile > outputFiles_
Definition: JobReport.h:254
edm::operator<<
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
Definition: HLTGlobalStatus.h:106
edm::propagate_const< std::ostream * >
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
edm::JobReport::RunReport::lumiSectionsToNEvents
std::map< unsigned int, unsigned long > lumiSectionsToNEvents
Definition: JobReport.h:110
edm::JobReport::reportMessageInfo
void reportMessageInfo(std::map< std::string, double > const &messageData)
Definition: JobReport.cc:555
InefficientDoubleROC.inputFileName
inputFileName
Definition: InefficientDoubleROC.py:437
edm::JobReport::JobReportImpl::getInputFileForToken
InputFile & getInputFileForToken(InputType inputType, Token t)
Definition: JobReport.cc:107
edm::JobReport::InputFile::fileHasBeenClosed
bool fileHasBeenClosed
Definition: JobReport.h:135
svgfig.load
def load(fileName)
Definition: svgfig.py:547
edm::JobReport::reportReadBranches
void reportReadBranches()
Definition: JobReport.cc:569
edm::JobReport::JobReportImpl::getOutputFileForToken
OutputFile & getOutputFileForToken(Token t)
Definition: JobReport.cc:131
edm::JobReport::outputFileClosed
void outputFileClosed(Token fileToken)
Definition: JobReport.cc:433
edm::EventNumber_t
unsigned long long EventNumber_t
Definition: RunLumiEventNumber.h:12
edm::JobReport::JobReportImpl::printedReadBranches_
bool printedReadBranches_
Definition: JobReport.h:258
edm::JobReport::InputFile::StringVector
std::vector< std::string > StringVector
Definition: JobReport.h:123
edm::JobReport::OutputFile::fastCopyingInputs
std::map< std::string, bool > fastCopyingInputs
Definition: JobReport.h:163
edm::JobReport::reportInputRunNumber
void reportInputRunNumber(unsigned int run)
Definition: JobReport.cc:471
edm::JobReport::JobReportImpl::associateInputLumiSection
void associateInputLumiSection(unsigned int runNumber, unsigned int lumiSection)
Definition: JobReport.cc:288
InputType.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::JobReport::InputFile::inputType
std::string inputType
Definition: JobReport.h:128
edm::JobReport::InputFile::inputSourceClassName
std::string inputSourceClassName
Definition: JobReport.h:129
edm::JobReport::JobReport
JobReport()
Definition: JobReport.cc:312
edm::JobReport::OutputFile::contributingInputs
std::vector< Token > contributingInputs
Definition: JobReport.h:161
edm::JobReport::reportLumiSection
void reportLumiSection(JobReport::Token token, unsigned int run, unsigned int lumiSectId, unsigned long nEvents=0)
Definition: JobReport.cc:458
edm::JobReport::OutputFile::StringVector
InputFile::StringVector StringVector
Definition: JobReport.h:149
edm::JobReport::InputFile::moduleLabel
std::string moduleLabel
Definition: JobReport.h:130
edm::JobReport::OutputFile::numEventsWritten
std::size_t numEventsWritten
Definition: JobReport.h:159
edm::JobReport::OutputFile
Definition: JobReport.h:148
mutex
static std::mutex mutex
Definition: Proxy.cc:8
edm::JobReport::JobReportImpl::flushFiles
void flushFiles(void)
Definition: JobReport.cc:237
edm::JobReport::reportRandomStateFile
void reportRandomStateFile(std::string const &name)
Definition: JobReport.cc:638
edm::JobReport::JobReportImpl::associateRun
void associateRun(JobReport::Token token, unsigned int runNumber)
Definition: JobReport.cc:255
edm::JobReport::RunReport::runNumber
RunNumber runNumber
Definition: JobReport.h:109
edm::JobReport::reportRunNumber
void reportRunNumber(JobReport::Token token, unsigned int run)
Definition: JobReport.cc:469
edm::JobReport::eventReadFromFile
void eventReadFromFile(InputType inputType, Token fileToken)
Definition: JobReport.cc:366
edm::JobReport::~JobReport
~JobReport()
Definition: JobReport.cc:305
submitPVResolutionJobs.err
err
Definition: submitPVResolutionJobs.py:85
edm::JobReport::JobReportImpl::readBranches_
std::map< std::string, long long > readBranches_
Definition: JobReport.h:255
edm::JobReport::write_mutex
std::mutex write_mutex
Definition: JobReport.h:431
edm::JobReport::InputFile::guid
std::string guid
Definition: JobReport.h:131
edm::JobReport::InputFile::fastClonedBranches
std::set< std::string > fastClonedBranches
Definition: JobReport.h:136
edm::JobReport::impl
edm::propagate_const< std::unique_ptr< JobReportImpl > > & impl()
Definition: JobReport.h:427
edm::JobReport::AtomicLongLong::value
std::atomic< long long > & value()
Definition: JobReport.h:172
alignCSCRings.r
r
Definition: alignCSCRings.py:93
edm::JobReport::reportSkippedFile
void reportSkippedFile(std::string const &pfn, std::string const &lfn)
Definition: JobReport.cc:506
edm::JobReport::reportMemoryInfo
void reportMemoryInfo(std::vector< std::string > const &memoryData)
Definition: JobReport.cc:541
writedatasetfile.run
run
Definition: writedatasetfile.py:27
edm::JobReport::impl_
edm::propagate_const< std::unique_ptr< JobReportImpl > > impl_
Definition: JobReport.h:430
edm::JobReport::reportFallbackAttempt
void reportFallbackAttempt(std::string const &pfn, std::string const &lfn, std::string const &err)
Definition: JobReport.cc:523
edm::JobReport::reportFastCopyingStatus
void reportFastCopyingStatus(Token t, std::string const &inputFileName, bool fastCopying)
Definition: JobReport.cc:451
edm::JobReport::JobReportImpl::JobReportImpl
JobReportImpl(JobReportImpl const &)=delete
edm::JobReport::OutputFile::guid
std::string guid
Definition: JobReport.h:156
edm::JobReport::reportSkippedEvent
void reportSkippedEvent(RunNumber_t run, EventNumber_t event)
Definition: JobReport.cc:439
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
edm::JobReport::AtomicLongLong::AtomicLongLong
AtomicLongLong()
Definition: JobReport.h:170
edm::JobReport::InputFile::logicalFileName
std::string logicalFileName
Definition: JobReport.h:125
edm::JobReport::JobReportImpl::insertInputForOutputs
void insertInputForOutputs(InputType inputType, Token t)
Definition: JobReport.cc:151
edm::JobReport::OutputFile::contributingInputsSecSource
tbb::concurrent_vector< Token > contributingInputsSecSource
Definition: JobReport.h:162
edm::JobReport::InputFile::numEventsRead
std::size_t numEventsRead
Definition: JobReport.h:132
edm::JobReport::OutputFile::physicalFileName
std::string physicalFileName
Definition: JobReport.h:152
edm::JobReport::reportPerformanceSummary
void reportPerformanceSummary(std::string const &metricClass, std::map< std::string, std::string > const &metrics)
Definition: JobReport.cc:652
edm::JobReport::JobReportImpl::writeInputFile
void writeInputFile(InputFile const &f)
Definition: JobReport.cc:168
edm::JobReport::reportPerformanceForModule
void reportPerformanceForModule(std::string const &metricClass, std::string const &moduleName, std::map< std::string, std::string > const &metrics)
Definition: JobReport.cc:671
edm::JobReport::JobReportImpl::inputFiles_
std::vector< InputFile > inputFiles_
Definition: JobReport.h:252
edm::JobReport::JobReportImpl
Definition: JobReport.h:179
HerwigMaxPtPartonFilter_cfi.moduleLabel
moduleLabel
Definition: HerwigMaxPtPartonFilter_cfi.py:4
edm::JobReport::inputFileOpened
Token inputFileOpened(std::string const &physicalFileName, std::string const &logicalFileName, std::string const &catalog, std::string const &inputType, std::string const &inputSourceClassName, std::string const &moduleLabel, std::string const &guid, std::vector< std::string > const &branchNames)
Definition: JobReport.cc:320
event
Definition: event.py:1
nEvents
UInt_t nEvents
Definition: hcalCalib.cc:40
edm::JobReport::operator=
JobReport & operator=(JobReport const &)=delete
get_underlying_safe.h
edm::JobReport::InputFile::physicalFileName
std::string physicalFileName
Definition: JobReport.h:126
edm::JobReport::outputFileOpened
Token outputFileOpened(std::string const &physicalFileName, std::string const &logicalFileName, std::string const &catalog, std::string const &outputModuleClassName, std::string const &moduleLabel, std::string const &guid, std::string const &dataType, std::string const &branchHash, std::vector< std::string > const &branchNames)
Definition: JobReport.cc:389
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
edm::JobReport::JobReportImpl::readBranchesSecSource_
tbb::concurrent_unordered_map< std::string, AtomicLongLong > readBranchesSecSource_
Definition: JobReport.h:257
edm::JobReport::JobReportImpl::readBranchesSecFile_
std::map< std::string, long long > readBranchesSecFile_
Definition: JobReport.h:256
edm::JobReport::reportError
void reportError(std::string const &shortDesc, std::string const &longDesc, int const &exitCode)
Definition: JobReport.cc:493
edm::JobReport::JobReportImpl::ost
std::ostream *& ost()
Definition: JobReport.h:250
edm::JobReport::OutputFile::branchHash
std::string branchHash
Definition: JobReport.h:158
edm::JobReport::InputFile::catalog
std::string catalog
Definition: JobReport.h:127
edm::JobReport
Definition: JobReport.h:103
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:316
edm::JobReport::OutputFile::dataType
std::string dataType
Definition: JobReport.h:157