Classes | Public Types | Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
art::MemoryTracker Class Reference

Classes

struct  Config
 

Public Types

using Parameters = ServiceTable< Config >
 

Public Member Functions

 MemoryTracker (fhicl::ParameterSet const &)
 
 MemoryTracker (Parameters const &, ActivityRegistry &)
 

Static Public Attributes

static constexpr bool service_handle_allowed {false}
 

Private Types

template<unsigned N>
using name_array = cet::sqlite::name_array< N >
 
using peakUsage_t = cet::sqlite::Ntuple< string, double, string >
 
using otherInfo_t = cet::sqlite::Ntuple< string, string, string, double, double >
 
using memEvent_t = cet::sqlite::Ntuple< string, uint32_t, uint32_t, uint32_t, double, double >
 
using memModule_t = cet::sqlite::Ntuple< string, uint32_t, uint32_t, uint32_t, string, string, string, double, double >
 
using memEventHeap_t = cet::sqlite::Ntuple< string, uint32_t, uint32_t, uint32_t, int, int, int, int, int, int, int >
 
using memModuleHeap_t = cet::sqlite::Ntuple< string, uint32_t, uint32_t, uint32_t, string, string, string, int, int, int, int, int, int, int >
 

Private Member Functions

void prePathProcessing (PathContext const &pc)
 
void recordOtherData (ModuleDescription const &md, string const &step)
 
void recordOtherData (ModuleContext const &mc, string const &step)
 
void recordEventData (Event const &e, string const &step)
 
void recordModuleData (ModuleContext const &mc, string const &step)
 
void postEndJob ()
 
bool checkMallocConfig_ (string const &, bool)
 
void recordPeakUsages_ ()
 
void flushTables_ ()
 
void summary_ ()
 

Private Attributes

LinuxProcMgr procInfo_ {}
 
string const fileName_
 
unique_ptr< cet::sqlite::Connection > const db_
 
bool const overwriteContents_
 
bool const includeMallocInfo_
 
EventID currentEventID_ {EventID::invalidEvent()}
 
name_array< 3u > peakUsageColumns_ {{"Name", "Value", "Description"}}
 
name_array< 5u > otherInfoColumns_
 
name_array< 6u > eventColumns_
 
name_array< 9u > moduleColumns_
 
name_array< 11u > eventHeapColumns_
 
name_array< 14u > moduleHeapColumns_
 
peakUsage_t peakUsageTable_
 
otherInfo_t otherInfoTable_
 
memEvent_t eventTable_
 
memModule_t moduleTable_
 
unique_ptr< memEventHeap_teventHeapTable_
 
unique_ptr< memModuleHeap_tmoduleHeapTable_
 

Detailed Description

Definition at line 17 of file MemoryTrackerDarwin_service.cc.

Member Typedef Documentation

using art::MemoryTracker::memEvent_t = cet::sqlite::Ntuple<string, uint32_t, uint32_t, uint32_t, double, double>
private

Definition at line 72 of file MemoryTrackerLinux_service.cc.

using art::MemoryTracker::memEventHeap_t = cet::sqlite::Ntuple<string, uint32_t, uint32_t, uint32_t, int, int, int, int, int, int, int>
private

Definition at line 92 of file MemoryTrackerLinux_service.cc.

using art::MemoryTracker::memModule_t = cet::sqlite::Ntuple<string, uint32_t, uint32_t, uint32_t, string, string, string, double, double>
private

Definition at line 81 of file MemoryTrackerLinux_service.cc.

using art::MemoryTracker::memModuleHeap_t = cet::sqlite::Ntuple<string, uint32_t, uint32_t, uint32_t, string, string, string, int, int, int, int, int, int, int>
private

Definition at line 106 of file MemoryTrackerLinux_service.cc.

template<unsigned N>
using art::MemoryTracker::name_array = cet::sqlite::name_array<N>
private

Definition at line 67 of file MemoryTrackerLinux_service.cc.

Definition at line 70 of file MemoryTrackerLinux_service.cc.

Definition at line 126 of file MemoryTrackerLinux_service.cc.

Definition at line 68 of file MemoryTrackerLinux_service.cc.

Constructor & Destructor Documentation

art::MemoryTracker::MemoryTracker ( fhicl::ParameterSet const &  )
inline

Definition at line 21 of file MemoryTrackerDarwin_service.cc.

22  {
23  mf::LogAbsolute("MemoryTracker")
24  << "\n"
25  << "The MemoryTracker service is not supported for this operating "
26  "system.\n"
27  << "If desired, please log an issue with:\n\n"
28  << "https://cdcvs.fnal.gov/redmine/projects/cet-is/issues/new\n\n";
29  }
MaybeLogger_< ELseverityLevel::ELsev_severe, true > LogAbsolute
art::MemoryTracker::MemoryTracker ( Parameters const &  ,
ActivityRegistry  
)

Member Function Documentation

bool art::MemoryTracker::checkMallocConfig_ ( string const &  dbfilename,
bool  include 
)
private

Definition at line 371 of file MemoryTrackerLinux_service.cc.

373  {
374  if (include && dbfilename.empty()) {
375  string const errmsg =
376  "\n'includeMallocInfo : true' is valid only if a nonempty db filename is specified:\n\n"s +
377  " MemoryTracker: {\n"
378  " includeMallocInfo: true\n"
379  " dbOutput: {\n"
380  " filename: \"your_filename.db\"\n"
381  " }\n"
382  " }\n\n";
383  throw Exception{errors::Configuration} << errmsg;
384  }
385  return include;
386  }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:27
void include(std::istream &in, std::string &result)
Definition: include.cc:63
static QCString * s
Definition: config.cpp:1042
void art::MemoryTracker::flushTables_ ( )
private

Definition at line 398 of file MemoryTrackerLinux_service.cc.

399  {
401  eventTable_.flush();
404  if (eventHeapTable_) {
405  eventHeapTable_->flush();
406  }
407  if (moduleHeapTable_) {
408  moduleHeapTable_->flush();
409  }
410  }
unique_ptr< memEventHeap_t > eventHeapTable_
unique_ptr< memModuleHeap_t > moduleHeapTable_
void art::MemoryTracker::postEndJob ( )
private
void art::MemoryTracker::prePathProcessing ( PathContext const &  pc)
private
void art::MemoryTracker::recordEventData ( Event const &  e,
string const &  step 
)
private

Definition at line 304 of file MemoryTrackerLinux_service.cc.

305  {
306  currentEventID_ = e.id();
307  auto const currentMemory = procInfo_.getCurrentData();
312  LinuxProcData::getValueInMB<vsize_t>(currentMemory),
313  LinuxProcData::getValueInMB<rss_t>(currentMemory));
314  if (includeMallocInfo_) {
315  auto minfo = LinuxMallInfo{}.get();
316  eventHeapTable_->insert(step,
320  minfo.arena,
321  minfo.ordblks,
322  minfo.keepcost,
323  minfo.hblkhd,
324  minfo.hblks,
325  minfo.uordblks,
326  minfo.fordblks);
327  }
328  }
void insert(Args const ...)
Definition: Ntuple.h:231
unique_ptr< memEventHeap_t > eventHeapTable_
LinuxProcData::proc_tuple getCurrentData() const noexcept(false)
Definition: LinuxProcMgr.cc:69
RunNumber_t run() const
Definition: EventID.h:98
const double e
struct mallinfo get() const
Definition: LinuxMallInfo.h:42
EventNumber_t event() const
Definition: EventID.h:116
SubRunNumber_t subRun() const
Definition: EventID.h:110
void art::MemoryTracker::recordModuleData ( ModuleContext const &  mc,
string const &  step 
)
private

Definition at line 331 of file MemoryTrackerLinux_service.cc.

332  {
333  auto const currentMemory = procInfo_.getCurrentData();
338  mc.pathName(),
339  mc.moduleLabel(),
340  mc.moduleName(),
341  LinuxProcData::getValueInMB<vsize_t>(currentMemory),
342  LinuxProcData::getValueInMB<rss_t>(currentMemory));
343  if (includeMallocInfo_) {
344  auto minfo = LinuxMallInfo{}.get();
345  moduleHeapTable_->insert(step,
349  mc.pathName(),
350  mc.moduleLabel(),
351  mc.moduleName(),
352  minfo.arena,
353  minfo.ordblks,
354  minfo.keepcost,
355  minfo.hblkhd,
356  minfo.hblks,
357  minfo.uordblks,
358  minfo.fordblks);
359  }
360  }
void insert(Args const ...)
Definition: Ntuple.h:231
LinuxProcData::proc_tuple getCurrentData() const noexcept(false)
Definition: LinuxProcMgr.cc:69
RunNumber_t run() const
Definition: EventID.h:98
struct mallinfo get() const
Definition: LinuxMallInfo.h:42
EventNumber_t event() const
Definition: EventID.h:116
unique_ptr< memModuleHeap_t > moduleHeapTable_
SubRunNumber_t subRun() const
Definition: EventID.h:110
void art::MemoryTracker::recordOtherData ( ModuleDescription const &  md,
string const &  step 
)
private

Definition at line 292 of file MemoryTrackerLinux_service.cc.

294  {
295  auto const data = procInfo_.getCurrentData();
297  md.moduleLabel(),
298  md.moduleName(),
299  LinuxProcData::getValueInMB<vsize_t>(data),
300  LinuxProcData::getValueInMB<rss_t>(data));
301  }
void insert(Args const ...)
Definition: Ntuple.h:231
LinuxProcData::proc_tuple getCurrentData() const noexcept(false)
Definition: LinuxProcMgr.cc:69
void art::MemoryTracker::recordOtherData ( ModuleContext const &  mc,
string const &  step 
)
private

Definition at line 286 of file MemoryTrackerLinux_service.cc.

287  {
288  recordOtherData(mc.moduleDescription(), step);
289  }
void recordOtherData(ModuleDescription const &md, string const &step)
void art::MemoryTracker::recordPeakUsages_ ( )
private

Definition at line 389 of file MemoryTrackerLinux_service.cc.

390  {
392  "VmPeak", procInfo_.getVmPeak(), "Peak virtual memory (MB)");
394  "VmHWM", procInfo_.getVmHWM(), "Peak resident set size (MB)");
395  }
void insert(Args const ...)
Definition: Ntuple.h:231
double getVmHWM() const noexcept(false)
Definition: LinuxProcMgr.h:34
double getVmPeak() const noexcept(false)
Definition: LinuxProcMgr.h:29
void art::MemoryTracker::summary_ ( )
private

Definition at line 413 of file MemoryTrackerLinux_service.cc.

414  {
415  using namespace cet::sqlite;
416  using namespace std;
417  query_result<double> rVMax;
418  query_result<double> rRMax;
419  rVMax << select("Value")
420  .from(*db_, peakUsageTable_.name())
421  .where("Name='VmPeak'");
422  rRMax << select("Value")
423  .from(*db_, peakUsageTable_.name())
424  .where("Name='VmHWM'");
425  mf::LogAbsolute log{"MemoryTracker"};
426  HorizontalRule const rule{100};
427  log << '\n' << rule('=') << '\n';
428  log << std::left << "MemoryTracker summary (base-10 MB units used)\n\n";
429  log << " Peak virtual memory usage (VmPeak) : " << unique_value(rVMax)
430  << " MB\n"
431  << " Peak resident set size usage (VmHWM): " << unique_value(rRMax)
432  << " MB\n";
433  if (!(fileName_.empty() || fileName_ == ":memory:")) {
434  log << " Details saved in: '" << fileName_ << "'\n";
435  }
436  log << rule('=');
437  }
T unique_value(query_result< T > const &r)
Definition: query_result.h:94
STL namespace.
std::string const & name() const
Definition: Ntuple.h:145
unique_ptr< cet::sqlite::Connection > const db_
auto select(T const &...t)
Definition: select.h:146

Member Data Documentation

EventID art::MemoryTracker::currentEventID_ {EventID::invalidEvent()}
private

Definition at line 150 of file MemoryTrackerLinux_service.cc.

unique_ptr<cet::sqlite::Connection> const art::MemoryTracker::db_
private

Definition at line 143 of file MemoryTrackerLinux_service.cc.

name_array<6u> art::MemoryTracker::eventColumns_
private
Initial value:
{
{"Step", "Run", "SubRun", "Event", "Vsize", "RSS"}}

Definition at line 154 of file MemoryTrackerLinux_service.cc.

name_array<11u> art::MemoryTracker::eventHeapColumns_
private
Initial value:
{{"Step",
"Run",
"SubRun",
"Event",
"arena",
"ordblks",
"keepcost",
"hblkhd",
"hblks",
"uordblks",
"fordblks"}}

Definition at line 165 of file MemoryTrackerLinux_service.cc.

unique_ptr<memEventHeap_t> art::MemoryTracker::eventHeapTable_
private

Definition at line 194 of file MemoryTrackerLinux_service.cc.

memEvent_t art::MemoryTracker::eventTable_
private

Definition at line 192 of file MemoryTrackerLinux_service.cc.

string const art::MemoryTracker::fileName_
private

Definition at line 142 of file MemoryTrackerLinux_service.cc.

bool const art::MemoryTracker::includeMallocInfo_
private

Definition at line 145 of file MemoryTrackerLinux_service.cc.

name_array<9u> art::MemoryTracker::moduleColumns_
private
Initial value:
{{"Step",
"Run",
"SubRun",
"Event",
"Path",
"ModuleLabel",
"ModuleType",
"Vsize",
"RSS"}}

Definition at line 156 of file MemoryTrackerLinux_service.cc.

name_array<14u> art::MemoryTracker::moduleHeapColumns_
private
Initial value:
{{"Step",
"Run",
"SubRun",
"Event",
"Path",
"ModuleLabel",
"ModuleType",
"arena",
"ordblks",
"keepcost",
"hblkhd",
"hblks",
"uordblks",
"fordblks"}}

Definition at line 176 of file MemoryTrackerLinux_service.cc.

unique_ptr<memModuleHeap_t> art::MemoryTracker::moduleHeapTable_
private

Definition at line 195 of file MemoryTrackerLinux_service.cc.

memModule_t art::MemoryTracker::moduleTable_
private

Definition at line 193 of file MemoryTrackerLinux_service.cc.

name_array<5u> art::MemoryTracker::otherInfoColumns_
private
Initial value:
{
{"Step", "ModuleLabel", "ModuleType", "Vsize", "RSS"}}

Definition at line 152 of file MemoryTrackerLinux_service.cc.

otherInfo_t art::MemoryTracker::otherInfoTable_
private

Definition at line 191 of file MemoryTrackerLinux_service.cc.

bool const art::MemoryTracker::overwriteContents_
private

Definition at line 144 of file MemoryTrackerLinux_service.cc.

name_array<3u> art::MemoryTracker::peakUsageColumns_ {{"Name", "Value", "Description"}}
private

Definition at line 151 of file MemoryTrackerLinux_service.cc.

peakUsage_t art::MemoryTracker::peakUsageTable_
private

Definition at line 190 of file MemoryTrackerLinux_service.cc.

LinuxProcMgr art::MemoryTracker::procInfo_ {}
private

Definition at line 141 of file MemoryTrackerLinux_service.cc.

static constexpr bool art::MemoryTracker::service_handle_allowed {false}
static

Definition at line 19 of file MemoryTrackerDarwin_service.cc.


The documentation for this class was generated from the following files: