CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
86 
87 #include <atomic>
88 #include <cstddef>
89 #include <iosfwd>
90 #include <map>
91 #include <mutex>
92 #include <set>
93 #include <string>
94 #include <vector>
95 
96 #include "boost/scoped_ptr.hpp"
97 #include "tbb/concurrent_unordered_map.h"
98 #include "tbb/concurrent_vector.h"
99 
100 namespace edm {
101 
102  class JobReport {
103  public:
104 
105  typedef unsigned int RunNumber;
106  typedef std::size_t Token;
107 
108  struct RunReport {
110  std::set<unsigned int> lumiSections;
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 {
149 
151 
156  std::string moduleLabel; // name of class instance
160  std::size_t numEventsWritten;
162  std::vector<Token> contributingInputs;
163  tbb::concurrent_vector<Token> contributingInputsSecSource;
164  std::map<std::string, bool> fastCopyingInputs;
165  std::map<RunNumber, RunReport> runReports;
167  };
168 
170  public:
173  std::atomic<long long>& value() { return value_; }
174  std::atomic<long long> const& value() const { return value_; }
175  private:
176  std::atomic<long long> value_;
177  };
178 
179  struct JobReportImpl {
180 
181  JobReportImpl& operator=(JobReportImpl const&) = delete;
182  JobReportImpl(JobReportImpl const&) = delete;
183 
186 
187  /*
188  * Add the input file token provided to every output
189  * file currently available.
190  * Used whenever a new input file is opened, it's token
191  * is added to all open output files as a contributor
192  */
193  void insertInputForOutputs(InputType inputType, Token t);
194 
195  /*
196  * Associate a Lumi Section to all open output files
197  *
198  */
199  void associateLumiSection(JobReport::Token token, unsigned int runNumber, unsigned int lumiSection);
200 
201  /*
202  * Associate a Lumi Section to all open input files
203  *
204  */
205  void associateInputLumiSection(unsigned int runNumber, unsigned int lumiSection);
206 
207  /*
208  * Associate a run to all open output files
209  */
210  void associateRun(JobReport::Token token, unsigned int runNumber);
211 
212  /*
213  * Associate a run to all open output files
214  */
215  void associateInputRun(unsigned int runNumber);
216 
217  /*
218  * Write an InputFile object to the Logger
219  * Generate XML string for InputFile instance and dispatch to
220  * job report via MessageLogger
221  */
222  void writeInputFile(InputFile const& f);
223 
224  /*
225  * Write an OutputFile object to the Logger
226  * Generate an XML string for the OutputFile provided and
227  * dispatch it to the logger
228  * Contributing input tokens are resolved to the input LFN and PFN
229  *
230  * TODO: We have not yet addressed the issue where we cleanup not
231  * contributing input files.
232  * Also, it is possible to get fake input to output file mappings
233  * if an input file is open already when a new output file is opened
234  * but the input gets closed without contributing events to the
235  * output file due to filtering etc.
236  *
237  */
238  void writeOutputFile(OutputFile const& f);
239 
240  /*
241  * Flush all open files to logger in event of a problem.
242  */
243  void flushFiles(void);
244 
245  JobReportImpl(std::ostream* iOst): printedReadBranches_(false), ost_(iOst) {}
246 
247  std::vector<InputFile> inputFiles_;
248  tbb::concurrent_vector<InputFile> inputFilesSecSource_;
249  std::vector<OutputFile> outputFiles_;
250  std::map<std::string, long long> readBranches_;
251  std::map<std::string, long long> readBranchesSecFile_;
252  tbb::concurrent_unordered_map<std::string, AtomicLongLong> readBranchesSecSource_;
255  std::ostream* ost_;
256  };
257 
258  JobReport();
259  //Does not take ownership of pointer
260  JobReport(std::ostream* outputStream);
261 
262  JobReport& operator=(JobReport const&) = delete;
263  JobReport(JobReport const&) = delete;
264 
265  ~JobReport();
266 
268  void childAfterFork(std::string const& jobReportFile, unsigned int childIndex, unsigned int numberOfChildren);
269 
270  void parentBeforeFork(std::string const& jobReportFile, unsigned int numberOfChildren);
271 
272  void parentAfterFork(std::string const& jobReportFile);
273 
277  Token inputFileOpened(std::string const& physicalFileName,
278  std::string const& logicalFileName,
279  std::string const& catalog,
280  std::string const& inputType,
281  std::string const& inputSourceClassName,
282  std::string const& moduleLabel,
283  std::string const& guid,
284  std::vector<std::string> const& branchNames);
285 
288  void eventReadFromFile(InputType inputType, Token fileToken);
289 
294  // CMS-THREADING Current implementation requires an instance of an
295  // OuputModule run on only one thread at a time.
296  void reportDataType(Token fileToken, std::string const& dataType);
297 
298 
302  void inputFileClosed(InputType inputType, Token fileToken);
303 
307  Token outputFileOpened(std::string const& physicalFileName,
308  std::string const& logicalFileName,
309  std::string const& catalog,
310  std::string const& outputModuleClassName,
311  std::string const& moduleLabel,
312  std::string const& guid,
313  std::string const& dataType,
314  std::string const& branchHash,
315  std::vector<std::string> const& branchNames);
316 
319  // CMS-THREADING Current implementation requires an instance of an
320  // OuputModule run on only one thread at a time.
322 
326  void outputFileClosed(Token fileToken);
327 
329 
334  void reportRunNumber(JobReport::Token token, unsigned int run);
335 
340  void reportLumiSection(JobReport::Token token, unsigned int run, unsigned int lumiSectId);
341 
347  void reportInputLumiSection(unsigned int run, unsigned int lumiSectId);
348 
352  void reportInputRunNumber(unsigned int run);
353 
359  void reportError(std::string const& shortDesc,
360  std::string const& longDesc,
361  int const& exitCode);
362 
368  void reportSkippedFile(std::string const& pfn, std::string const& lfn);
369 
370  void reportFallbackAttempt(std::string const& pfn, std::string const& lfn, std::string const& err);
371 
373  std::map<std::string, std::string> const& fileData) ;
374 
381  void reportMemoryInfo(std::vector<std::string> const& memoryData);
382 
389  void reportMessageInfo(std::map<std::string, double> const& messageData);
390 
397  void reportReadBranches();
398 
400  void reportReadBranch(InputType inputType, std::string const& branchName);
401 
403  void reportFastClonedBranches(std::set<std::string> const& fastClonedBranches, long long nEvents);
404 
409 
410  /*
411  * Report information about fast copying. Called for each open output file
412  * whenever an input file is opened.
413  */
414  void reportFastCopyingStatus(Token t, std::string const& inputFileName, bool fastCopying);
415 
423  void reportPerformanceSummary(std::string const& metricClass,
424  std::map<std::string, std::string> const& metrics);
425 
426  void reportPerformanceForModule(std::string const& metricClass,
427  std::string const& moduleName,
428  std::map<std::string, std::string> const& metrics);
429 
431  std::string dumpFiles(void);
432 
433  protected:
434  boost::scoped_ptr<JobReportImpl>& impl() {return impl_;}
435 
436  private:
437  boost::scoped_ptr<JobReportImpl> impl_;
439  };
440 
441  std::ostream& operator<< (std::ostream& os, JobReport::InputFile const& f);
442  std::ostream& operator<< (std::ostream& os, JobReport::OutputFile const& f);
443 }
444 #endif
tuple t
Definition: tree.py:139
InputType
Definition: InputType.h:5
void reportSkippedFile(std::string const &pfn, std::string const &lfn)
Definition: JobReport.cc:597
std::string inputSourceClassName
Definition: JobReport.h:129
list pfn
Definition: dbtoconf.py:76
std::string outputModuleClassName
Definition: JobReport.h:155
std::string physicalFileName
Definition: JobReport.h:153
void associateRun(JobReport::Token token, unsigned int runNumber)
Definition: JobReport.cc:275
void reportMemoryInfo(std::vector< std::string > const &memoryData)
Definition: JobReport.cc:629
void associateLumiSection(JobReport::Token token, unsigned int runNumber, unsigned int lumiSection)
Definition: JobReport.cc:295
void reportInputRunNumber(unsigned int run)
Definition: JobReport.cc:554
void eventReadFromFile(InputType inputType, Token fileToken)
Definition: JobReport.cc:441
std::map< std::string, long long > readBranches_
Definition: JobReport.h:250
static boost::mutex mutex
Definition: LHEProxy.cc:11
std::mutex write_mutex
Definition: JobReport.h:438
void reportFallbackAttempt(std::string const &pfn, std::string const &lfn, std::string const &err)
Definition: JobReport.cc:613
std::string logicalFileName
Definition: JobReport.h:125
std::set< std::string > fastClonedBranches
Definition: JobReport.h:136
unsigned long long EventNumber_t
std::atomic< long long > & value()
Definition: JobReport.h:173
std::map< std::string, bool > fastCopyingInputs
Definition: JobReport.h:164
std::string logicalFileName
Definition: JobReport.h:152
void reportFastCopyingStatus(Token t, std::string const &inputFileName, bool fastCopying)
Definition: JobReport.cc:533
JobReportImpl(JobReportImpl const &)=delete
void reportRunNumber(JobReport::Token token, unsigned int run)
Definition: JobReport.cc:549
void reportRandomStateFile(std::string const &name)
Definition: JobReport.cc:719
JobReport & operator=(JobReport const &)=delete
std::vector< std::string > StringVector
Definition: JobReport.h:123
uint16_t size_type
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:393
std::vector< InputFile > inputFiles_
Definition: JobReport.h:247
void reportPerformanceForModule(std::string const &metricClass, std::string const &moduleName, std::map< std::string, std::string > const &metrics)
Definition: JobReport.cc:754
std::map< RunNumber, RunReport > runReports
Definition: JobReport.h:134
std::vector< Token > contributingInputs
Definition: JobReport.h:162
std::string physicalFileName
Definition: JobReport.h:126
void reportSkippedEvent(RunNumber_t run, EventNumber_t event)
Definition: JobReport.cc:520
tbb::concurrent_unordered_map< std::string, AtomicLongLong > readBranchesSecSource_
Definition: JobReport.h:252
void insertInputForOutputs(InputType inputType, Token t)
Definition: JobReport.cc:176
InputFile::StringVector StringVector
Definition: JobReport.h:150
std::string moduleName(Provenance const &provenance)
Definition: Provenance.cc:27
std::size_t numEventsRead
Definition: JobReport.h:132
void writeInputFile(InputFile const &f)
Definition: JobReport.cc:193
StringVector branchNames
Definition: JobReport.h:161
JobReportImpl & operator=(JobReportImpl const &)=delete
void reportInputLumiSection(unsigned int run, unsigned int lumiSectId)
Definition: JobReport.cc:544
std::map< std::string, long long > readBranchesSecFile_
Definition: JobReport.h:251
def load
Definition: svgfig.py:546
std::map< RunNumber, RunReport > runReports
Definition: JobReport.h:165
void reportPerformanceSummary(std::string const &metricClass, std::map< std::string, std::string > const &metrics)
Definition: JobReport.cc:733
void childAfterFork(std::string const &jobReportFile, unsigned int childIndex, unsigned int numberOfChildren)
New output file for child.
Definition: JobReport.cc:383
std::set< unsigned int > lumiSections
Definition: JobReport.h:110
double f[11][100]
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:467
AtomicLongLong(AtomicLongLong const &r)
Definition: JobReport.h:172
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
std::atomic< long long > const & value() const
Definition: JobReport.h:174
std::vector< OutputFile > outputFiles_
Definition: JobReport.h:249
void reportError(std::string const &shortDesc, std::string const &longDesc, int const &exitCode)
Definition: JobReport.cc:580
unsigned int RunNumber
Definition: JobReport.h:105
std::size_t Token
Definition: JobReport.h:106
void associateInputRun(unsigned int runNumber)
Definition: JobReport.cc:283
void reportReadBranch(InputType inputType, std::string const &branchName)
Inform the job report that a branch has been read.
Definition: JobReport.cc:694
std::size_t numEventsWritten
Definition: JobReport.h:160
void reportFastClonedBranches(std::set< std::string > const &fastClonedBranches, long long nEvents)
Inform the job report that branches have been fast Cloned.
Definition: JobReport.cc:709
boost::scoped_ptr< JobReportImpl > impl_
Definition: JobReport.h:437
void eventWrittenToFile(Token fileToken, RunNumber_t run, EventNumber_t event)
Definition: JobReport.cc:507
tbb::concurrent_vector< InputFile > inputFilesSecSource_
Definition: JobReport.h:248
std::atomic< long long > value_
Definition: JobReport.h:176
void parentAfterFork(std::string const &jobReportFile)
Definition: JobReport.cc:379
void reportMessageInfo(std::map< std::string, double > const &messageData)
Definition: JobReport.cc:644
std::string dumpFiles(void)
debug/test util
Definition: JobReport.cc:777
void parentBeforeFork(std::string const &jobReportFile, unsigned int numberOfChildren)
Definition: JobReport.cc:361
boost::scoped_ptr< JobReportImpl > & impl()
Definition: JobReport.h:434
void reportAnalysisFile(std::string const &fileName, std::map< std::string, std::string > const &fileData)
Definition: JobReport.cc:559
std::vector< InputFile >::size_type lastOpenedPrimaryInputFile_
Definition: JobReport.h:254
void outputFileClosed(Token fileToken)
Definition: JobReport.cc:513
void writeOutputFile(OutputFile const &f)
Definition: JobReport.cc:220
JobReportImpl(std::ostream *iOst)
Definition: JobReport.h:245
unsigned int RunNumber_t
InputFile & getInputFileForToken(InputType inputType, Token t)
Definition: JobReport.cc:119
void reportLumiSection(JobReport::Token token, unsigned int run, unsigned int lumiSectId)
Definition: JobReport.cc:539
void reportDataType(Token fileToken, std::string const &dataType)
Definition: JobReport.cc:447
volatile std::atomic< bool > shutdown_flag false
UInt_t nEvents
Definition: hcalCalib.cc:42
tbb::concurrent_vector< Token > contributingInputsSecSource
Definition: JobReport.h:163
StringVector branchNames
Definition: JobReport.h:133
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
void inputFileClosed(InputType inputType, Token fileToken)
Definition: JobReport.cc:453
void associateInputLumiSection(unsigned int runNumber, unsigned int lumiSection)
Definition: JobReport.cc:305
void reportReadBranches()
Definition: JobReport.cc:660
OutputFile & getOutputFileForToken(Token t)
Definition: JobReport.cc:151