13 #include <unordered_set> 14 #include <unordered_map> 17 #include <boost/format.hpp> 18 #include <boost/range/irange.hpp> 46 template <
class Rep,
class Period>
47 double ms(std::chrono::duration<Rep, Period> duration)
49 return std::chrono::duration_cast<std::chrono::duration<double, std::milli>>(duration).
count();;
53 template <
class Rep,
class Period>
54 double ms(boost::chrono::duration<Rep, Period> duration)
56 return boost::chrono::duration_cast<boost::chrono::duration<double, boost::milli>>(duration).
count();;
82 time_real = boost::chrono::nanoseconds::zero();
163 paths(process.paths_.
size()),
164 endpaths(process.endPaths_.
size())
181 for (
unsigned int i: boost::irange(0ul,
paths.size()))
184 for (
unsigned int i: boost::irange(0ul,
endpaths.size()))
204 highlight( groups.
size() ),
230 for (
unsigned int i: boost::irange(0ul,
highlight.size()))
233 for (
unsigned int i: boost::irange(0ul,
modules.size()))
236 for (
unsigned int i: boost::irange(0ul,
processes.size()))
259 #ifdef DEBUG_THREAD_CONCURRENCY 260 id = std::this_thread::get_id();
261 #endif // DEBUG_THREAD_CONCURRENCY 270 #ifdef DEBUG_THREAD_CONCURRENCY 271 assert(std::this_thread::get_id() ==
id);
272 #endif // DEBUG_THREAD_CONCURRENCY 278 store.
time_real = new_time_real - time_real;
279 store.
allocated = new_allocated - allocated;
281 time_thread = new_time_thread;
282 time_real = new_time_real;
283 allocated = new_allocated;
284 deallocated = new_deallocated;
321 unsigned int lumisections,
330 name +
" time_thread",
331 title +
" processing time (cpu)",
340 title +
" processing time (real)",
344 time_real_->SetXTitle(
"processing time [ms]");
351 title +
" allocated memory",
359 name +
" deallocated",
360 title +
" deallocated memory",
372 name +
" time_thread_byls",
373 title +
" processing time (cpu) vs. lumisection",
374 lumisections, 0.5, lumisections + 0.5,
382 name +
" time_real_byls",
383 title +
" processing time (real) vs. lumisection",
384 lumisections, 0.5, lumisections + 0.5,
394 name +
" allocated_byls",
395 title +
" allocated memory vs. lumisection",
396 lumisections, 0.5, lumisections + 0.5,
404 name +
" deallocated_byls",
405 title +
" deallocated memory vs. lumisection",
406 lumisections, 0.5, lumisections + 0.5,
486 module_time_thread_total_(
nullptr),
487 module_time_real_total_(
nullptr),
488 module_allocated_total_(
nullptr),
489 module_deallocated_total_(
nullptr)
512 unsigned int lumisections,
525 bins + 1, -0.5, bins + 0.5
529 "module_time_thread_total",
530 "total module time (cpu)",
531 bins, -0.5, bins - 0.5
535 "module_time_real_total",
536 "total module time (real)",
537 bins, -0.5, bins - 0.5
543 "module_allocated_total",
544 "total allocated memory",
545 bins, -0.5, bins - 0.5
549 "module_deallocated_total",
550 "total deallocated memory",
551 bins, -0.5, bins - 0.5
555 for (
unsigned int bin: boost::irange(0u, bins)) {
579 for (
unsigned int i = 0;
i < path.
last; ++
i) {
603 paths_(process.paths_.
size()),
604 endpaths_(process.endPaths_.
size())
625 unsigned int lumisections,
631 "process " + process.
name_,
"process " + process.
name_,
637 for (
unsigned int id: boost::irange(0ul,
paths_.size()))
645 for (
unsigned int id: boost::irange(0ul,
endpaths_.size()))
664 for (
unsigned int id: boost::irange(0ul,
paths_.size()))
668 for (
unsigned int id: boost::irange(0ul,
endpaths_.size()))
674 highlight_(groups.
size()),
675 modules_(job.
size()),
699 std::vector<GroupOfModules>
const& groups,
703 unsigned int lumisections,
724 for (
unsigned int group: boost::irange(0ul, groups.size())) {
734 for (
unsigned int pid: boost::irange(0ul, job.
processes().size())) {
746 for (
unsigned int id:
process.modules_)
771 for (
unsigned int id: boost::irange(0ul,
modules_.size()))
774 for (
unsigned int pid: boost::irange(0ul,
processes_.size()))
793 enable_dqm_( config.getUntrackedParameter<bool>(
"enableDQM" ) ),
796 enable_dqm_byls_( config.getUntrackedParameter<bool>(
"enableDQMbyLumiSection" ) ),
803 config.getUntrackedParameter<
double>(
"dqmPathTimeResolution" ),
804 config.getUntrackedParameter<
double>(
"dqmPathMemoryRange" ),
805 config.getUntrackedParameter<
double>(
"dqmPathMemoryResolution" ) } ),
807 config.getUntrackedParameter<
double>(
"dqmModuleTimeResolution" ),
808 config.getUntrackedParameter<
double>(
"dqmModuleMemoryRange" ),
809 config.getUntrackedParameter<
double>(
"dqmModuleMemoryResolution") } ),
889 auto const&
module = stream.modules[
id];
903 return ms(stream.total.time_real);
911 return ms(stream.processes[pid].total.time_real);
959 for (
unsigned int id: boost::irange(0ul, desc.paths_.size()))
960 if (desc.paths_[
id].name_ == path)
961 return ms(stream.processes[
pid].paths[
id].total.time_real);
962 for (
unsigned int id: boost::irange(0ul, desc.endPaths_.size()))
963 if (desc.paths_[
id].name_ == path)
964 return ms(stream.processes[
pid].endpaths[
id].total.time_real);
977 for (
unsigned int id: boost::irange(0ul, desc.paths_.size()))
978 if (desc.paths_[
id].name_ == path)
979 return ms(stream.processes[pid].paths[
id].total.time_real);
980 for (
unsigned int id: boost::irange(0ul, desc.endPaths_.size()))
981 if (desc.paths_[
id].name_ == path)
982 return ms(stream.processes[pid].endpaths[
id].total.time_real);
994 return ms(stream.highlight[
group].time_real);
1004 LogDebug(
"FastTimerService") <<
"The FastTimerService received is currently not monitoring the signal \"" << signal <<
"\".\n";
1012 edm::LogWarning(
"FastTimerService") <<
"The FastTimerService received the unsupported signal \"" << signal <<
"\".\n" 1013 <<
"Please report how to reproduce the issue to cms-hlt@cern.ch .";
1289 template <
typename T>
1292 out <<
"FastReport ";
1293 if (label.size() < 60)
1294 for (
unsigned int i = (60-label.size()) / 2;
i > 0; --
i)
1296 out <<
' ' << label <<
" Summary ";
1297 if (label.size() < 60)
1298 for (
unsigned int i = (59-label.size()) / 2;
i > 0; --
i)
1303 template <
typename T>
1306 out <<
"FastReport CPU time Real time Allocated Deallocated " << label <<
"\n";
1310 template <
typename T>
1313 out <<
boost::format(
"FastReport %10.3f ms %10.3f ms %+10d kB %+10d kB %s\n")
1321 template <
typename T>
1333 for (
unsigned int m: proc_d.modules_) {
1347 for (
unsigned int p = 0;
p <
proc.paths.size(); ++
p) {
1348 auto const&
name = proc_d.paths_[
p].name_;
1353 for (
unsigned int p = 0;
p <
proc.endpaths.size(); ++
p) {
1354 auto const&
name = proc_d.endPaths_[
p].name_;
1374 template <
typename T>
1378 out <<
"FastReport CPU time avg. when run Real time avg. when run Alloc, avg. when run Dealloc. avg. when run " <<
label;
1381 out <<
"FastReport CPU time avg. Real time avg. Alloc, avg. Dealloc. avg. " <<
label;
1385 template <
typename T>
1388 out <<
boost::format(
"FastReport %10.3f ms %10.3f ms %+10d kB %+10d kB %s\n")
1391 % (events ? kB(data.
allocated) / events : 0)
1396 template <
typename T>
1399 out <<
boost::format(
"FastReport %10.3f ms %10.3f ms %10.3f ms %10.3f ms %+10d kB %+10d kB %+10d kB %+10d kB %s\n")
1402 % (events ? kB(data.
allocated) / events : 0) % (active ? kB(data.
allocated) / active : 0)
1407 template <
typename T>
1419 for (
unsigned int m: proc_d.modules_) {
1433 for (
unsigned int p = 0;
p <
proc.paths.size(); ++
p) {
1434 auto const&
name = proc_d.paths_[
p].name_;
1439 for (
unsigned int p = 0;
p <
proc.endpaths.size(); ++
p) {
1440 auto const&
name = proc_d.endPaths_[
p].name_;
1479 unsigned int old_value = check.fetch_add(1, std::memory_order_acq_rel);
1500 auto &
data = stream.processes[
pid].total;
1501 for (
unsigned int i:
process.modules_)
1502 data += stream.modules[
i].total;
1503 stream.total +=
data;
1513 stream.highlight[
group] += stream.modules[
i].total;
1549 unsigned int id = md.
id();
1553 ++stream.modules[
id].events;
1562 unsigned int id = pc.
pathID();
1565 data.status =
false;
1575 unsigned int id = pc.
pathID();
1580 unsigned int index =
path.modules_on_path_.empty() ? 0 : status.
index() + 1;
1581 data.last =
path.modules_on_path_.empty() ? 0 :
path.last_dependency_of_module_[status.
index()];
1583 for (
unsigned int i = 0;
i <
index; ++
i) {
1584 auto const&
module = stream.modules[
path.modules_on_path_[
i]];
1587 for (
unsigned int i = 0;
i <
data.last; ++
i) {
1588 auto const&
module = stream.modules[
path.modules_and_dependencies_[
i]];
1603 unsigned int id = md.
id();
1608 ++stream.modules[
id].events;
1762 desc.
addUntracked<
bool>(
"enableDQMbyLumiSection",
false);
1763 desc.
addUntracked<
bool>(
"enableDQMbyProcesses",
false);
1766 desc.
addUntracked<
double>(
"dqmMemoryRange", 1000000. );
1767 desc.
addUntracked<
double>(
"dqmMemoryResolution", 5000. );
1769 desc.
addUntracked<
double>(
"dqmPathTimeResolution", 0.5);
1770 desc.
addUntracked<
double>(
"dqmPathMemoryRange", 1000000. );
1771 desc.
addUntracked<
double>(
"dqmPathMemoryResolution", 5000. );
1772 desc.
addUntracked<
double>(
"dqmModuleTimeRange", 40. );
1773 desc.
addUntracked<
double>(
"dqmModuleTimeResolution", 0.2);
1774 desc.
addUntracked<
double>(
"dqmModuleMemoryRange", 100000. );
1775 desc.
addUntracked<
double>(
"dqmModuleMemoryResolution", 500. );
1776 desc.
addUntracked<
unsigned>(
"dqmLumiSectionsRange", 2500 );
1780 highlightModulesDescription.
addUntracked<std::vector<std::string>>(
"modules", {});
1781 highlightModulesDescription.addUntracked<
std::string>(
"label",
"producers");
1801 descriptions.
add(
"FastTimerService", desc);
void preGlobalBeginRun(edm::GlobalContext const &)
void preModuleEventDelayedGet(edm::StreamContext const &, edm::ModuleCallingContext const &)
const bool print_run_summary_
unsigned int maxNumberOfThreads() const
void fill(Resources const &, unsigned int lumisection)
void setComment(std::string const &value)
T getUntrackedParameter(std::string const &, T const &) const
void postStreamBeginRun(edm::StreamContext const &)
double queryEventTime(edm::StreamID) const
void postGlobalEndLumi(edm::GlobalContext const &)
void postGlobalBeginLumi(edm::GlobalContext const &)
void postStreamEndLumi(edm::StreamContext const &)
std::vector< edm::ParameterSet > highlight_module_psets_
void postModuleGlobalEndLumi(edm::GlobalContext const &, edm::ModuleCallingContext const &)
void preEventReadFromSource(edm::StreamContext const &, edm::ModuleCallingContext const &)
void preGlobalEndRun(edm::GlobalContext const &)
void preBeginJob(edm::PathsAndConsumesOfModulesBase const &, edm::ProcessContext const &)
unsigned int concurrent_threads_
std::vector< unsigned int > modules_and_dependencies_
void postEventReadFromSource(edm::StreamContext const &, edm::ModuleCallingContext const &)
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
double queryHighlightTime(edm::StreamID sid, std::string const &label) const
const PlotRanges dqm_event_ranges_
void postModuleGlobalEndRun(edm::GlobalContext const &, edm::ModuleCallingContext const &)
void postModuleEvent(edm::StreamContext const &, edm::ModuleCallingContext const &)
std::vector< GroupOfModules > highlight_modules_
ResourcesPerJob job_summary_
MonitorElement * bookProfile(Args &&...args)
PlotsPerJob(ProcessCallGraph const &job, std::vector< GroupOfModules > const &groups)
unsigned int processId(edm::ProcessContext const &) const
TrainProcessor *const proc
PlotsPerProcess(ProcessCallGraph::ProcessType const &)
void preGlobalEndLumi(edm::GlobalContext const &)
std::vector< ResourcesPerPath > endpaths
TH1D * module_time_real_total_
const std::string & pwd(void)
TProfile * allocated_byls_
void book(DQMStore::IBooker &, std::string const &, ProcessCallGraph const &, ProcessCallGraph::PathType const &, PlotRanges const &ranges, unsigned int lumisections, bool byls)
double queryModuleTime_(edm::StreamID, unsigned int id) const
bool isFirstSubprocess(edm::StreamContext const &)
const bool enable_dqm_bynproc_
unsigned int concurrent_runs_
boost::chrono::nanoseconds time_real
TH1D * getTH1D(void) const
std::unique_ptr< std::atomic< unsigned int >[]> subprocess_global_run_check_
std::vector< ResourcesPerJob > streams_
RunIndex const & runIndex() const
void postPathEvent(edm::StreamContext const &, edm::PathContext const &, edm::HLTPathStatus const &)
std::vector< PlotsPerElement > highlight_
void preModuleGlobalBeginLumi(edm::GlobalContext const &, edm::ModuleCallingContext const &)
void book(DQMStore::IBooker &, ProcessCallGraph const &, ProcessCallGraph::ProcessType const &, PlotRanges const &event_ranges, PlotRanges const &path_ranges, unsigned int lumisections, bool bypath, bool byls)
ResourcesPerProcess & operator+=(ResourcesPerProcess const &other)
LuminosityBlockNumber_t luminosityBlock() const
const bool print_job_summary_
std::string const & moduleLabel() const
const bool enable_dqm_bypath_
edm::ModuleDescription const & source() const
static unsigned int getUniqueID()
Returns a unique id each time called. Intended to be passed to ModuleDescription's constructor's modI...
tbb::enumerable_thread_specific< Measurement, tbb::cache_aligned_allocator< Measurement >, tbb::ets_key_per_instance > threads_
void postStreamBeginLumi(edm::StreamContext const &)
void printSummary(T &out, ResourcesPerJob const &, std::string const &label) const
const PlotRanges dqm_path_ranges_
RunIndex const & runIndex() const
unsigned int maxNumberOfStreams() const
ResourcesPerProcess operator+(ResourcesPerProcess const &other) const
ResourcesPerJob operator+(ResourcesPerJob const &other) const
std::vector< ResourcesPerModule > modules
void printEvent(T &out, ResourcesPerJob const &) const
void printHeader(T &out, std::string const &label) const
void postModuleStreamEndLumi(edm::StreamContext const &, edm::ModuleCallingContext const &)
std::mutex summary_mutex_
TProfile * time_thread_byls_
ResourcesPerJob & operator+=(ResourcesPerJob const &other)
std::vector< PlotsPerJob > stream_plots_
void printSummaryHeader(T &out, std::string const &label, bool detaile) const
void fill(ProcessCallGraph::ProcessType const &, ResourcesPerJob const &, ResourcesPerProcess const &, unsigned int ls)
double queryModuleTime(edm::StreamID, const edm::ModuleDescription &module) const
TProfile * time_real_byls_
TH1D * module_allocated_total_
void prePathEvent(edm::StreamContext const &, edm::PathContext const &)
std::vector< ResourcesPerJob > run_summary_
void printEventHeader(T &out, std::string const &label) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
FastTimerService(const edm::ParameterSet &, edm::ActivityRegistry &)
void preModuleStreamEndLumi(edm::StreamContext const &, edm::ModuleCallingContext const &)
TH1D * module_time_thread_total_
void postEvent(edm::StreamContext const &)
std::unique_ptr< std::atomic< unsigned int >[]> subprocess_lumisection_check_
void preBeginJob(edm::PathsAndConsumesOfModulesBase const &, edm::ProcessContext const &)
void postGlobalEndRun(edm::GlobalContext const &)
static uint64_t deallocated()
ModuleDescription const * moduleDescription() const
std::unique_ptr< std::atomic< unsigned int >[]> subprocess_event_check_
void fill_fraction(Resources const &, Resources const &, unsigned int lumisection)
std::vector< ProcessType > const & processes() const
MonitorElement * book1D(Args &&...args)
ResourcesPerModule operator+(ResourcesPerModule const &other) const
const unsigned int dqm_lumisections_range_
void postStreamEndRun(edm::StreamContext const &)
std::vector< PathType > paths_
void preModuleEvent(edm::StreamContext const &, edm::ModuleCallingContext const &)
ResourcesPerPath & operator+=(ResourcesPerPath const &other)
std::vector< PlotsPerElement > modules_
ProcessType const & processDescription(unsigned int) const
ParameterDescriptionNode * addOptionalNode(ParameterDescriptionNode const &node, bool writeToCfi)
void preSourceConstruction(edm::ModuleDescription const &)
void printSummaryLine(T &out, Resources const &data, uint64_t events, std::string const &label) const
unsigned int pathID() const
format
Some error handling for the usage.
ProcessContext const * processContext() const
void printEventLine(T &out, Resources const &data, std::string const &label) const
void mergeAndResetMEsRunSummaryCache(uint32_t run, uint32_t streamId, uint32_t moduleId)
Resources operator+(Resources const &other) const
std::vector< Resources > highlight
const bool enable_dqm_bymodule_
bin
set the eta bin as selection string.
StreamID const & streamID() const
const PlotRanges dqm_module_ranges_
std::vector< PlotsPerPath > endpaths_
static bool is_available()
const bool enable_dqm_byls_
std::vector< PlotsPerProcess > processes_
TProfile * deallocated_byls_
void postModuleEventDelayedGet(edm::StreamContext const &, edm::ModuleCallingContext const &)
const bool print_event_summary_
unsigned int value() const
void setCurrentFolder(const std::string &fullpath)
unsigned long long uint64_t
void postModuleStreamBeginLumi(edm::StreamContext const &, edm::ModuleCallingContext const &)
void book(DQMStore::IBooker &, ProcessCallGraph const &, std::vector< GroupOfModules > const &, PlotRanges const &event_ranges, PlotRanges const &path_ranges, PlotRanges const &module_ranges, unsigned int lumisections, bool bymodule, bool bypath, bool byls)
double querySourceTime(edm::StreamID) const
void preModuleStreamEndRun(edm::StreamContext const &, edm::ModuleCallingContext const &)
void postModuleStreamEndRun(edm::StreamContext const &, edm::ModuleCallingContext const &)
static uint64_t allocated()
void postModuleStreamBeginRun(edm::StreamContext const &, edm::ModuleCallingContext const &)
TH1F * getTH1F(void) const
void preSourceEvent(edm::StreamID)
boost::chrono::nanoseconds time_thread
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void preEvent(edm::StreamContext const &)
void postGlobalBeginRun(edm::GlobalContext const &)
ProcessContext const * processContext() const
void preStreamBeginLumi(edm::StreamContext const &)
ResourcesPerProcess(ProcessCallGraph::ProcessType const &process)
void postSourceEvent(edm::StreamID)
void preModuleStreamBeginLumi(edm::StreamContext const &, edm::ModuleCallingContext const &)
void preStreamEndRun(edm::StreamContext const &)
char data[epos_bytes_allocation]
void preModuleStreamBeginRun(edm::StreamContext const &, edm::ModuleCallingContext const &)
void preStreamEndLumi(edm::StreamContext const &)
void measure_and_store(Resources &store)
ResourcesPerModule & operator+=(ResourcesPerModule const &other)
std::vector< PathType > endPaths_
TProfile * getTProfile(void) const
void unsupportedSignal(std::string signal) const
void postModuleEventPrefetching(edm::StreamContext const &, edm::ModuleCallingContext const &)
void preModuleGlobalEndLumi(edm::GlobalContext const &, edm::ModuleCallingContext const &)
unsigned int size() const
edm::ModuleDescription const & module(unsigned int module) const
void ignoredSignal(std::string signal) const
double queryPathTime(edm::StreamID, std::string const &path) const
void preGlobalBeginLumi(edm::GlobalContext const &)
unsigned int maxNumberOfConcurrentRuns() const
Resources & operator+=(Resources const &other)
void preModuleEventPrefetching(edm::StreamContext const &, edm::ModuleCallingContext const &)
void preSourceConstruction(edm::ModuleDescription const &)
void preModuleGlobalEndRun(edm::GlobalContext const &, edm::ModuleCallingContext const &)
tbb::concurrent_unordered_set< std::string > unsupported_signals_
std::vector< PlotsPerPath > paths_
EventID const & eventID() const
void postModuleGlobalBeginRun(edm::GlobalContext const &, edm::ModuleCallingContext const &)
std::vector< ResourcesPerProcess > processes
double queryModuleTimeByLabel(edm::StreamID, std::string const &module) const
boost::date_time::subsecond_duration< boost::posix_time::time_duration, 1000000000 > nanoseconds
void book(DQMStore::IBooker &, std::string const &name, std::string const &title, PlotRanges const &ranges, unsigned int lumisections, bool byls)
ProcessCallGraph callgraph_
void mergeAndResetMEsLuminositySummaryCache(uint32_t run, uint32_t lumi, uint32_t streamId, uint32_t moduleId)
void postModuleGlobalBeginLumi(edm::GlobalContext const &, edm::ModuleCallingContext const &)
void preStreamBeginRun(edm::StreamContext const &)
std::vector< ResourcesPerPath > paths
MonitorElement * book1DD(Args &&...args)
bool isSubProcess() const
ResourcesPerPath operator+(ResourcesPerPath const &other) const
void preModuleGlobalBeginRun(edm::GlobalContext const &, edm::ModuleCallingContext const &)
ParameterDescriptionBase * addVPSetUntracked(U const &iLabel, ParameterSetDescription const &validator, std::vector< ParameterSet > const &defaults)
static std::string const source
std::unique_ptr< std::atomic< unsigned int >[]> subprocess_run_check_
std::vector< unsigned int > modules_
unsigned int concurrent_streams_
bool isLastSubprocess(std::atomic< unsigned int > &check)
void preallocate(edm::service::SystemBounds const &)
void fill(ProcessCallGraph const &, ResourcesPerJob const &, unsigned int ls)
TH1D * module_deallocated_total_
void fill(ProcessCallGraph::PathType const &, ResourcesPerJob const &, ResourcesPerPath const &, unsigned int lumisection)
unsigned int index() const