CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends
edm::service::SimpleMemoryCheck Class Reference

Classes

struct  SignificantEvent
 
struct  SignificantModule
 

Public Member Functions

void postBeginJob ()
 
void postEndJob ()
 
void postEvent (StreamContext const &)
 
void postModule (StreamContext const &, ModuleCallingContext const &)
 
void postModuleBeginJob (const ModuleDescription &)
 
void postModuleConstruction (const ModuleDescription &)
 
void postSourceConstruction (const ModuleDescription &)
 
void postSourceEvent (StreamID)
 
void preModule (StreamContext const &, ModuleCallingContext const &)
 
void preSourceConstruction (const ModuleDescription &)
 
 SimpleMemoryCheck (const ParameterSet &, ActivityRegistry &)
 
 ~SimpleMemoryCheck ()
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Types

typedef std::map< std::string, SignificantModuleSignificantModulesMap
 

Private Member Functions

void andPrint (const std::string &type, const std::string &mdlabel, const std::string &mdname) const
 
double averageGrowthRate (double current, double past, int count)
 
std::string eventStatOutput (std::string title, SignificantEvent const &e) const
 
void eventStatOutput (std::string title, SignificantEvent const &e, std::map< std::string, std::string > &m) const
 
ProcInfo fetch ()
 
smapsInfo fetchSmaps ()
 
std::string mallOutput (std::string title, size_t const &n) const
 
void openFiles ()
 
double pageSize () const
 
char const * smapsLineBuffer () const
 
char *& smapsLineBuffer ()
 
void update ()
 
void updateAndPrint (const std::string &type, const std::string &mdlabel, const std::string &mdname)
 
void updateEventStats (edm::EventID const &e)
 
void updateMax ()
 
void updateModuleMemoryStats (SignificantModule &m, double dv, edm::EventID const &)
 

Private Attributes

ProcInfo a_
 
ProcInfo b_
 
std::atomic< int > count_
 
edm::propagate_const< ProcInfo * > current_
 
smapsInfo currentSmaps_
 
SignificantEvent eventDeltaRssT1_
 
SignificantEvent eventDeltaRssT2_
 
SignificantEvent eventDeltaRssT3_
 
SignificantEvent eventL1_
 
SignificantEvent eventL2_
 
SignificantEvent eventM_
 
SignificantEvent eventR1_
 
SignificantEvent eventR2_
 
SignificantEvent eventRssT1_
 
SignificantEvent eventRssT2_
 
SignificantEvent eventRssT3_
 
SignificantEvent eventT1_
 
SignificantEvent eventT2_
 
SignificantEvent eventT3_
 
double growthRateRss_
 
double growthRateVsize_
 
bool jobReportOutputOnly_
 
ProcInfo max_
 
std::atomic< bool > measurementUnderway_
 
double moduleEntryVsize_
 
std::atomic< unsigned int > moduleID_
 
std::atomic< bool > moduleMeasurementUnderway_
 
SignificantModulesMap modules_
 
std::atomic< unsigned int > moduleStreamID_
 
bool moduleSummaryRequested_
 
bool monitorPssAndPrivate_
 
int num_to_skip_
 
bool oncePerEventMode_
 
double pg_size_
 
ProcInfoFetcher piFetcher_
 
edm::propagate_const< ProcInfo * > previous_
 
bool showMallocInfo_
 
edm::propagate_const< FILE * > smapsFile_
 
edm::propagate_const< char * > smapsLineBuffer_
 
size_t smapsLineBufferLen_
 

Friends

std::ostream & operator<< (std::ostream &os, SimpleMemoryCheck::SignificantEvent const &se)
 
std::ostream & operator<< (std::ostream &os, SimpleMemoryCheck::SignificantModule const &se)
 
struct SignificantEvent
 
struct SignificantModule
 

Detailed Description

Definition at line 77 of file SimpleMemoryCheck.cc.

Member Typedef Documentation

Definition at line 247 of file SimpleMemoryCheck.cc.

Constructor & Destructor Documentation

edm::service::SimpleMemoryCheck::SimpleMemoryCheck ( const ParameterSet ,
ActivityRegistry  
)

Definition at line 329 of file SimpleMemoryCheck.cc.

References edm::MallocOptionSetter::adjustMallocParams(), edm::MallocOptionSetter::error_message(), edm::MallocOptionSetter::get(), edm::getGlobalOptionSetter(), edm::ParameterSet::getUntrackedParameter(), edm::MallocOptionSetter::hasErrors(), moduleSummaryRequested_, oncePerEventMode_, openFiles(), postBeginJob(), postEndJob(), postEvent(), postModule(), postModuleBeginJob(), postModuleConstruction(), postSourceConstruction(), postSourceEvent(), preModule(), preSourceConstruction(), edm::MallocOptionSetter::set_mmap_max(), edm::MallocOptionSetter::set_mmap_thr(), edm::MallocOptionSetter::set_top_pad(), edm::MallocOptionSetter::set_trim_thr(), edm::ActivityRegistry::watchPostBeginJob(), edm::ActivityRegistry::watchPostEndJob(), edm::ActivityRegistry::watchPostEvent(), edm::ActivityRegistry::watchPostModuleBeginJob(), edm::ActivityRegistry::watchPostModuleConstruction(), edm::ActivityRegistry::watchPostModuleEvent(), edm::ActivityRegistry::watchPostSourceConstruction(), edm::ActivityRegistry::watchPostSourceEvent(), edm::ActivityRegistry::watchPreModuleEvent(), and edm::ActivityRegistry::watchPreSourceConstruction().

330  : a_(),
331  b_(),
332  current_(&a_),
333  previous_(&b_),
334  pg_size_(sysconf(_SC_PAGESIZE)) // getpagesize()
335  ,
336  num_to_skip_(iPS.getUntrackedParameter<int>("ignoreTotal")),
337  showMallocInfo_(iPS.getUntrackedParameter<bool>("showMallocInfo")),
338  oncePerEventMode_(iPS.getUntrackedParameter<bool>("oncePerEventMode")),
339  jobReportOutputOnly_(iPS.getUntrackedParameter<bool>("jobReportOutputOnly")),
340  monitorPssAndPrivate_(iPS.getUntrackedParameter<bool>("monitorPssAndPrivate")),
341  count_(),
342  smapsFile_(nullptr),
343  smapsLineBuffer_(nullptr),
346  growthRateRss_(),
347  moduleSummaryRequested_(iPS.getUntrackedParameter<bool>("moduleMemorySummary")),
348  measurementUnderway_(false) {
349  // changelog 2
350  // pg_size = (double)getpagesize();
351  std::ostringstream ost;
352 
353  openFiles();
354 
355  if (!oncePerEventMode_) { // default, prints on increases
356  iReg.watchPreSourceConstruction(this, &SimpleMemoryCheck::preSourceConstruction);
357  iReg.watchPostSourceConstruction(this, &SimpleMemoryCheck::postSourceConstruction);
358  iReg.watchPostSourceEvent(this, &SimpleMemoryCheck::postSourceEvent);
359  iReg.watchPostModuleConstruction(this, &SimpleMemoryCheck::postModuleConstruction);
360  iReg.watchPostModuleBeginJob(this, &SimpleMemoryCheck::postModuleBeginJob);
361  iReg.watchPostEvent(this, &SimpleMemoryCheck::postEvent);
362  iReg.watchPostModuleEvent(this, &SimpleMemoryCheck::postModule);
363  iReg.watchPostBeginJob(this, &SimpleMemoryCheck::postBeginJob);
364  iReg.watchPostEndJob(this, &SimpleMemoryCheck::postEndJob);
365  } else {
366  iReg.watchPostEvent(this, &SimpleMemoryCheck::postEvent);
367  iReg.watchPostEndJob(this, &SimpleMemoryCheck::postEndJob);
368  }
369  if (moduleSummaryRequested_) { // changelog 2
370  iReg.watchPreModuleEvent(this, &SimpleMemoryCheck::preModule);
371  if (oncePerEventMode_) {
372  iReg.watchPostModuleEvent(this, &SimpleMemoryCheck::postModule);
373  }
374  }
375 
376  // The following are not currenty used/implemented below for either
377  // of the print modes (but are left here for reference)
378  // iReg.watchPostBeginJob(this,
379  // &SimpleMemoryCheck::postBeginJob);
380  // iReg.watchPreProcessEvent(this,
381  // &SimpleMemoryCheck::preEventProcessing);
382  // iReg.watchPreModule(this,
383  // &SimpleMemoryCheck::preModule);
384 
385 #ifndef __SANITIZE_ADDRESS__
386  typedef MallocOpts::opt_type opt_type;
387  MallocOptionSetter& mopts = getGlobalOptionSetter();
388 
389  opt_type p_mmap_max = iPS.getUntrackedParameter<int>("M_MMAP_MAX"),
390  p_trim_thr = iPS.getUntrackedParameter<int>("M_TRIM_THRESHOLD"),
391  p_top_pad = iPS.getUntrackedParameter<int>("M_TOP_PAD"),
392  p_mmap_thr = iPS.getUntrackedParameter<int>("M_MMAP_THRESHOLD");
393 
394  if (p_mmap_max >= 0)
395  mopts.set_mmap_max(p_mmap_max);
396  if (p_trim_thr >= 0)
397  mopts.set_trim_thr(p_trim_thr);
398  if (p_top_pad >= 0)
399  mopts.set_top_pad(p_top_pad);
400  if (p_mmap_thr >= 0)
401  mopts.set_mmap_thr(p_mmap_thr);
402 
403  mopts.adjustMallocParams();
404 
405  if (mopts.hasErrors()) {
406  LogWarning("MemoryCheck") << "ERROR: Problem with setting malloc options\n" << mopts.error_message();
407  }
408 
409  if (iPS.getUntrackedParameter<bool>("dump") == true) {
410  MallocOpts mo = mopts.get();
411  LogWarning("MemoryCheck") << "Malloc options: " << mo << "\n";
412  }
413 #endif
414  }
void preSourceConstruction(const ModuleDescription &)
edm::propagate_const< ProcInfo * > current_
std::atomic< bool > measurementUnderway_
edm::propagate_const< FILE * > smapsFile_
edm::propagate_const< ProcInfo * > previous_
void preModule(StreamContext const &, ModuleCallingContext const &)
void postEvent(StreamContext const &)
edm::propagate_const< char * > smapsLineBuffer_
void postSourceConstruction(const ModuleDescription &)
void postModuleBeginJob(const ModuleDescription &)
void postModule(StreamContext const &, ModuleCallingContext const &)
void postModuleConstruction(const ModuleDescription &)
MallocOptionSetter & getGlobalOptionSetter()
Definition: MallocOpts.cc:196
edm::service::SimpleMemoryCheck::~SimpleMemoryCheck ( )

Definition at line 416 of file SimpleMemoryCheck.cc.

References smapsFile_, and smapsLineBuffer_.

416  {
417 #ifdef LINUX
418  if (nullptr != smapsFile_) {
419  fclose(smapsFile_);
420  }
421 #endif
422  if (smapsLineBuffer_) {
423  //getline will create the memory using malloc
424  free(smapsLineBuffer_);
425  }
426  }
edm::propagate_const< FILE * > smapsFile_
edm::propagate_const< char * > smapsLineBuffer_

Member Function Documentation

void edm::service::SimpleMemoryCheck::andPrint ( const std::string &  type,
const std::string &  mdlabel,
const std::string &  mdname 
) const
private

Definition at line 861 of file SimpleMemoryCheck.cc.

References count_, current_, jobReportOutputOnly_, max_, num_to_skip_, oncePerEventMode_, edm::service::ProcInfo::rss, showMallocInfo_, and edm::service::ProcInfo::vsize.

Referenced by postEvent(), and updateAndPrint().

863  {
864  if (not jobReportOutputOnly_ && ((*current_ > max_) || oncePerEventMode_)) {
865  if (count_ >= num_to_skip_) {
866  double deltaVSIZE = current_->vsize - max_.vsize;
867  double deltaRSS = current_->rss - max_.rss;
868  if (!showMallocInfo_) { // default
869  LogWarning("MemoryCheck") << "MemoryCheck: " << type << " " << mdname << ":" << mdlabel << " VSIZE "
870  << current_->vsize << " " << deltaVSIZE << " RSS " << current_->rss << " "
871  << deltaRSS;
872  } else {
873 #ifdef __linux__
874  struct mallinfo minfo = mallinfo();
875 #endif
876  LogWarning("MemoryCheck") << "MemoryCheck: " << type << " " << mdname << ":" << mdlabel << " VSIZE "
877  << current_->vsize << " " << deltaVSIZE << " RSS " << current_->rss << " "
878  << deltaRSS
879 #ifdef __linux__
880  << " HEAP-ARENA [ SIZE-BYTES " << minfo.arena << " N-UNUSED-CHUNKS "
881  << minfo.ordblks << " TOP-FREE-BYTES " << minfo.keepcost << " ]"
882  << " HEAP-MAPPED [ SIZE-BYTES " << minfo.hblkhd << " N-CHUNKS " << minfo.hblks
883  << " ]"
884  << " HEAP-USED-BYTES " << minfo.uordblks << " HEAP-UNUSED-BYTES "
885  << minfo.fordblks
886 #endif
887  ;
888  }
889  }
890  }
891  }
type
Definition: HCALResponse.h:21
edm::propagate_const< ProcInfo * > current_
double edm::service::SimpleMemoryCheck::averageGrowthRate ( double  current,
double  past,
int  count 
)
private

Definition at line 325 of file SimpleMemoryCheck.cc.

Referenced by postEndJob().

325  {
326  return (current - past) / (double)count;
327  }
std::string edm::service::SimpleMemoryCheck::eventStatOutput ( std::string  title,
SignificantEvent const &  e 
) const
private

Referenced by eventStatOutput(), and postEndJob().

void edm::service::SimpleMemoryCheck::eventStatOutput ( std::string  title,
SignificantEvent const &  e,
std::map< std::string, std::string > &  m 
) const
private

Definition at line 902 of file SimpleMemoryCheck.cc.

References edm::service::SimpleMemoryCheck::SignificantEvent::count, edm::service::d2str(), edm::service::SimpleMemoryCheck::SignificantEvent::deltaVsize, MillePedeFileConverter_cfg::e, edm::EventID::event(), edm::service::SimpleMemoryCheck::SignificantEvent::event, eventStatOutput(), edm::service::i2str(), mallOutput(), monitorPssAndPrivate_, gen::n, edm::service::SimpleMemoryCheck::SignificantEvent::privateSize, edm::service::SimpleMemoryCheck::SignificantEvent::pss, edm::service::SimpleMemoryCheck::SignificantEvent::rss, edm::EventID::run(), AlCaHLTBitMon_QueryRunRegistry::string, runGCPTkAlMap::title, and edm::service::SimpleMemoryCheck::SignificantEvent::vsize.

904  {
905  {
906  std::ostringstream os;
907  os << title << "-a-COUNT";
908  m.insert(std::make_pair(os.str(), i2str(e.count)));
909  }
910  {
911  std::ostringstream os;
912  os << title << "-b-RUN";
913  m.insert(std::make_pair(os.str(), d2str(static_cast<double>(e.event.run()))));
914  }
915  {
916  std::ostringstream os;
917  os << title << "-c-EVENT";
918  m.insert(std::make_pair(os.str(), d2str(static_cast<double>(e.event.event()))));
919  }
920  {
921  std::ostringstream os;
922  os << title << "-d-VSIZE";
923  m.insert(std::make_pair(os.str(), d2str(e.vsize)));
924  }
925  {
926  std::ostringstream os;
927  os << title << "-e-DELTV";
928  m.insert(std::make_pair(os.str(), d2str(e.deltaVsize)));
929  }
930  {
931  std::ostringstream os;
932  os << title << "-f-RSS";
933  m.insert(std::make_pair(os.str(), d2str(e.rss)));
934  }
935  if (monitorPssAndPrivate_) {
936  {
937  std::ostringstream os;
938  os << title << "-g-PRIVATE";
939  m.insert(std::make_pair(os.str(), d2str(e.privateSize)));
940  }
941  {
942  std::ostringstream os;
943  os << title << "-h-PSS";
944  m.insert(std::make_pair(os.str(), d2str(e.pss)));
945  }
946  }
947  } // eventStatOutput
static std::string i2str(int i)
static std::string d2str(double d)
ProcInfo edm::service::SimpleMemoryCheck::fetch ( )
private

Definition at line 289 of file SimpleMemoryCheck.cc.

Referenced by update().

289 { return piFetcher_.fetch(); }
smapsInfo edm::service::SimpleMemoryCheck::fetchSmaps ( )
private

Definition at line 291 of file SimpleMemoryCheck.cc.

References edm::service::smapsInfo::private_, edm::service::smapsInfo::pss_, and relativeConstraints::value.

Referenced by postEvent().

291  {
292  smapsInfo ret;
293  ret.private_ = 0;
294  ret.pss_ = 0;
295 #ifdef LINUX
296  fseek(smapsFile_, 0, SEEK_SET);
297  ssize_t read;
298 
299  /*
300  The format of the report is
301  Private_Clean: 0 kB
302  Private_Dirty: 72 kB
303  Swap: 0 kB
304  Pss: 72 kB
305  */
306 
307  while ((read = getline(&smapsLineBuffer(), &smapsLineBufferLen_, smapsFile_)) != -1) {
308  if (read > 14) {
309  //Private
310  if (0 == strncmp("Private_", smapsLineBuffer_, 8)) {
311  unsigned int value = atoi(smapsLineBuffer_ + 14);
312  //Convert from kB to MB
313  ret.private_ += static_cast<double>(value) / 1024.;
314  } else if (0 == strncmp("Pss:", smapsLineBuffer_, 4)) {
315  unsigned int value = atoi(smapsLineBuffer_ + 4);
316  //Convert from kB to MB
317  ret.pss_ += static_cast<double>(value) / 1024.;
318  }
319  }
320  }
321 #endif
322  return ret;
323  }
edm::propagate_const< FILE * > smapsFile_
char const * smapsLineBuffer() const
Definition: value.py:1
edm::propagate_const< char * > smapsLineBuffer_
void edm::service::SimpleMemoryCheck::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 428 of file SimpleMemoryCheck.cc.

References edm::ConfigurationDescriptions::add(), and edm::ParameterSetDescription::addUntracked().

428  {
430  desc.addUntracked<int>("ignoreTotal", 1);
431  desc.addUntracked<bool>("showMallocInfo", false);
432  desc.addUntracked<bool>("oncePerEventMode", false);
433  desc.addUntracked<bool>("jobReportOutputOnly", false);
434  desc.addUntracked<bool>("monitorPssAndPrivate", false);
435  desc.addUntracked<bool>("moduleMemorySummary", false);
436  desc.addUntracked<int>("M_MMAP_MAX", -1);
437  desc.addUntracked<int>("M_TRIM_THRESHOLD", -1);
438  desc.addUntracked<int>("M_TOP_PAD", -1);
439  desc.addUntracked<int>("M_MMAP_THRESHOLD", -1);
440  desc.addUntracked<bool>("dump", false);
441  descriptions.add("SimpleMemoryCheck", desc);
442  }
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::string edm::service::SimpleMemoryCheck::mallOutput ( std::string  title,
size_t const &  n 
) const
private

Referenced by eventStatOutput(), and postEndJob().

void edm::service::SimpleMemoryCheck::openFiles ( )
private

Definition at line 444 of file SimpleMemoryCheck.cc.

References edm::errors::Configuration, Exception, monitorPssAndPrivate_, and smapsFile_.

Referenced by SimpleMemoryCheck().

444  {
445 #ifdef LINUX
446  if (monitorPssAndPrivate_) {
447  std::ostringstream smapsNameOst;
448  smapsNameOst << "/proc/" << getpid() << "/smaps";
449  if ((smapsFile_ = fopen(smapsNameOst.str().c_str(), "r")) == nullptr) {
450  throw Exception(errors::Configuration) << "Failed to open smaps file " << smapsNameOst.str() << std::endl;
451  }
452  }
453 #endif
454  }
edm::propagate_const< FILE * > smapsFile_
double edm::service::SimpleMemoryCheck::pageSize ( ) const
inlineprivate
void edm::service::SimpleMemoryCheck::postBeginJob ( )

Definition at line 456 of file SimpleMemoryCheck.cc.

References current_, growthRateRss_, and growthRateVsize_.

Referenced by SimpleMemoryCheck().

456  {
457  growthRateVsize_ = current_->vsize;
458  growthRateRss_ = current_->rss;
459  }
edm::propagate_const< ProcInfo * > current_
void edm::service::SimpleMemoryCheck::postEndJob ( )

Definition at line 506 of file SimpleMemoryCheck.cc.

References averageGrowthRate(), taus_updatedMVAIds_cff::category, count_, current_, edm::service::d2str(), edm::service::SimpleMemoryCheck::SignificantEvent::deltaRss, eventDeltaRssT1_, eventDeltaRssT2_, eventDeltaRssT3_, eventL1_, eventL2_, eventM_, edm::service::SimpleMemoryCheck::SignificantModule::eventMaxDeltaV, eventR1_, eventR2_, eventRssT1_, eventRssT2_, eventRssT3_, eventStatOutput(), eventT1_, eventT2_, eventT3_, growthRateRss_, growthRateVsize_, edm::service::i2str(), jobReportOutputOnly_, label, funct::m, mallOutput(), edm::service::SimpleMemoryCheck::SignificantModule::maxDeltaVsize, edm::service::SimpleMemoryCheck::SignificantModule::maxEarlyVsize, modules_, moduleSummaryRequested_, edm::service::SimpleMemoryCheck::SignificantModule::postEarlyCount, edm::service::SimpleMemoryCheck::SignificantEvent::rss, AlCaHLTBitMon_QueryRunRegistry::string, edm::service::SimpleMemoryCheck::SignificantModule::totalDeltaVsize, edm::service::SimpleMemoryCheck::SignificantModule::totalEarlyVsize, relativeConstraints::value, and edm::service::SimpleMemoryCheck::SignificantEvent::vsize.

Referenced by SimpleMemoryCheck().

506  {
507  if (not jobReportOutputOnly_) {
508  LogAbsolute("MemoryReport") // changelog 1
509  << "MemoryReport> Peak virtual size " << eventT1_.vsize << " Mbytes"
510  << "\n"
511  << " Key events increasing vsize: \n"
512  << eventL2_ << "\n"
513  << eventL1_ << "\n"
514  << eventM_ << "\n"
515  << eventR1_ << "\n"
516  << eventR2_ << "\n"
517  << eventT3_ << "\n"
518  << eventT2_ << "\n"
519  << eventT1_;
520  }
521  if (moduleSummaryRequested_ and not jobReportOutputOnly_) { // changelog 1
522  LogAbsolute mmr("ModuleMemoryReport"); // at end of if block, mmr
523  // is destructed, causing
524  // message to be logged
525  mmr << "ModuleMemoryReport> Each line has module label and: \n";
526  mmr << " (after early ignored events) \n";
527  mmr << " count of times module executed; average increase in vsize \n";
528  mmr << " maximum increase in vsize; event on which maximum occurred \n";
529  mmr << " (during early ignored events) \n";
530  mmr << " total and maximum vsize increases \n \n";
531  for (SignificantModulesMap::iterator im = modules_.begin(); im != modules_.end(); ++im) {
532  SignificantModule const& m = im->second;
533  if (m.totalDeltaVsize == 0 && m.totalEarlyVsize == 0)
534  continue;
535  mmr << im->first << ": ";
536  mmr << "n = " << m.postEarlyCount;
537  if (m.postEarlyCount > 0) {
538  mmr << " avg = " << m.totalDeltaVsize / m.postEarlyCount;
539  }
540  mmr << " max = " << m.maxDeltaVsize << " " << m.eventMaxDeltaV;
541  if (m.totalEarlyVsize > 0) {
542  mmr << " early total: " << m.totalEarlyVsize;
543  mmr << " max: " << m.maxEarlyVsize;
544  }
545  mmr << "\n";
546  }
547  } // end of if; mmr goes out of scope; log message is queued
548 
549  Service<JobReport> reportSvc;
550  // changelog 1
551 #define SIMPLE_MEMORY_CHECK_ORIGINAL_XML_OUTPUT
552 #ifdef SIMPLE_MEMORY_CHECK_ORIGINAL_XML_OUTPUT
553  // std::map<std::string, double> reportData;
554  std::map<std::string, std::string> reportData;
555 
556  if (eventL2_.vsize > 0)
557  eventStatOutput("LargeVsizeIncreaseEventL2", eventL2_, reportData);
558  if (eventL1_.vsize > 0)
559  eventStatOutput("LargeVsizeIncreaseEventL1", eventL1_, reportData);
560  if (eventM_.vsize > 0)
561  eventStatOutput("LargestVsizeIncreaseEvent", eventM_, reportData);
562  if (eventR1_.vsize > 0)
563  eventStatOutput("LargeVsizeIncreaseEventR1", eventR1_, reportData);
564  if (eventR2_.vsize > 0)
565  eventStatOutput("LargeVsizeIncreaseEventR2", eventR2_, reportData);
566  if (eventT3_.vsize > 0)
567  eventStatOutput("ThirdLargestVsizeEventT3", eventT3_, reportData);
568  if (eventT2_.vsize > 0)
569  eventStatOutput("SecondLargestVsizeEventT2", eventT2_, reportData);
570  if (eventT1_.vsize > 0)
571  eventStatOutput("LargestVsizeEventT1", eventT1_, reportData);
572 
573  if (eventRssT3_.rss > 0)
574  eventStatOutput("ThirdLargestRssEvent", eventRssT3_, reportData);
575  if (eventRssT2_.rss > 0)
576  eventStatOutput("SecondLargestRssEvent", eventRssT2_, reportData);
577  if (eventRssT1_.rss > 0)
578  eventStatOutput("LargestRssEvent", eventRssT1_, reportData);
579  if (eventDeltaRssT3_.deltaRss > 0)
580  eventStatOutput("ThirdLargestIncreaseRssEvent", eventDeltaRssT3_, reportData);
581  if (eventDeltaRssT2_.deltaRss > 0)
582  eventStatOutput("SecondLargestIncreaseRssEvent", eventDeltaRssT2_, reportData);
583  if (eventDeltaRssT1_.deltaRss > 0)
584  eventStatOutput("LargestIncreaseRssEvent", eventDeltaRssT1_, reportData);
585 
586 #ifdef __linux__
587  struct mallinfo minfo = mallinfo();
588  reportData.insert(std::make_pair("HEAP_ARENA_SIZE_BYTES", i2str(minfo.arena)));
589  reportData.insert(std::make_pair("HEAP_ARENA_N_UNUSED_CHUNKS", i2str(minfo.ordblks)));
590  reportData.insert(std::make_pair("HEAP_TOP_FREE_BYTES", i2str(minfo.keepcost)));
591  reportData.insert(std::make_pair("HEAP_MAPPED_SIZE_BYTES", i2str(minfo.hblkhd)));
592  reportData.insert(std::make_pair("HEAP_MAPPED_N_CHUNKS", i2str(minfo.hblks)));
593  reportData.insert(std::make_pair("HEAP_USED_BYTES", i2str(minfo.uordblks)));
594  reportData.insert(std::make_pair("HEAP_UNUSED_BYTES", i2str(minfo.fordblks)));
595 #endif
596 
597  // Report Growth rates for VSize and Rss
598  reportData.insert(std::make_pair("AverageGrowthRateVsize",
600  reportData.insert(std::make_pair("PeakValueVsize", d2str(eventT1_.vsize)));
601  reportData.insert(
602  std::make_pair("AverageGrowthRateRss", d2str(averageGrowthRate(current_->rss, growthRateRss_, count_))));
603  reportData.insert(std::make_pair("PeakValueRss", d2str(eventRssT1_.rss)));
604 
605  if (moduleSummaryRequested_) { // changelog 2
606  for (SignificantModulesMap::iterator im = modules_.begin(); im != modules_.end(); ++im) {
607  SignificantModule const& m = im->second;
608  if (m.totalDeltaVsize == 0 && m.totalEarlyVsize == 0)
609  continue;
610  std::string label = im->first + ":";
611  reportData.insert(std::make_pair(label + "PostEarlyCount", i2str(m.postEarlyCount)));
612  if (m.postEarlyCount > 0) {
613  reportData.insert(std::make_pair(label + "AverageDeltaVsize", d2str(m.totalDeltaVsize / m.postEarlyCount)));
614  }
615  reportData.insert(std::make_pair(label + "MaxDeltaVsize", d2str(m.maxDeltaVsize)));
616  if (m.totalEarlyVsize > 0) {
617  reportData.insert(std::make_pair(label + "TotalEarlyVsize", d2str(m.totalEarlyVsize)));
618  reportData.insert(std::make_pair(label + "MaxEarlyDeltaVsize", d2str(m.maxEarlyVsize)));
619  }
620  }
621  }
622 
623  std::map<std::string, std::string> reportMemoryProperties;
624 
625  if (FILE* fmeminfo = fopen("/proc/meminfo", "r")) {
626  char buf[128];
627  char space[] = " ";
628  size_t value;
629  while (fgets(buf, sizeof(buf), fmeminfo)) {
630  char* saveptr;
631  char* token = nullptr;
632  token = strtok_r(buf, space, &saveptr);
633  if (token != nullptr) {
634  value = atol(strtok_r(nullptr, space, &saveptr));
635  std::string category = token;
636  reportMemoryProperties.insert(std::make_pair(category.substr(0, strlen(token) - 1), i2str(value)));
637  }
638  }
639 
640  fclose(fmeminfo);
641  }
642 
643  // reportSvc->reportMemoryInfo(reportData, reportMemoryProperties);
644  reportSvc->reportPerformanceSummary("ApplicationMemory", reportData);
645  reportSvc->reportPerformanceSummary("SystemMemory", reportMemoryProperties);
646 #endif
647 
648 #ifdef SIMPLE_MEMORY_CHECK_DIFFERENT_XML_OUTPUT
649  std::vector<std::string> reportData;
650 
651  if (eventL2_.vsize > 0)
652  reportData.push_back(eventStatOutput("LargeVsizeIncreaseEventL2", eventL2_));
653  if (eventL1_.vsize > 0)
654  reportData.push_back(eventStatOutput("LargeVsizeIncreaseEventL1", eventL1_));
655  if (eventM_.vsize > 0)
656  reportData.push_back(eventStatOutput("LargestVsizeIncreaseEvent", eventM_));
657  if (eventR1_.vsize > 0)
658  reportData.push_back(eventStatOutput("LargeVsizeIncreaseEventR1", eventR1_));
659  if (eventR2_.vsize > 0)
660  reportData.push_back(eventStatOutput("LargeVsizeIncreaseEventR2", eventR2_));
661  if (eventT3_.vsize > 0)
662  reportData.push_back(eventStatOutput("ThirdLargestVsizeEventT3", eventT3_));
663  if (eventT2_.vsize > 0)
664  reportData.push_back(eventStatOutput("SecondLargestVsizeEventT2", eventT2_));
665  if (eventT1_.vsize > 0)
666  reportData.push_back(eventStatOutput("LargestVsizeEventT1", eventT1_));
667 
668  if (eventRssT3_.rss > 0)
669  eventStatOutput("ThirdLargestRssEvent", eventRssT3_, reportData);
670  if (eventRssT2_.rss > 0)
671  eventStatOutput("SecondLargestRssEvent", eventRssT2_, reportData);
672  if (eventRssT1_.rss > 0)
673  eventStatOutput("LargestRssEvent", eventRssT1_, reportData);
674  if (eventDeltaRssT3_.deltaRss > 0)
675  eventStatOutput("ThirdLargestIncreaseRssEvent", eventDeltaRssT3_, reportData);
676  if (eventDeltaRssT2_.deltaRss > 0)
677  eventStatOutput("SecondLargestIncreaseRssEvent", eventDeltaRssT2_, reportData);
678  if (eventDeltaRssT1_.deltaRss > 0)
679  eventStatOutput("LargestIncreaseRssEvent", eventDeltaRssT1_, reportData);
680 
681  struct mallinfo minfo = mallinfo();
682  reportData.push_back(mallOutput("HEAP_ARENA_SIZE_BYTES", minfo.arena));
683  reportData.push_back(mallOutput("HEAP_ARENA_N_UNUSED_CHUNKS", minfo.ordblks));
684  reportData.push_back(mallOutput("HEAP_TOP_FREE_BYTES", minfo.keepcost));
685  reportData.push_back(mallOutput("HEAP_MAPPED_SIZE_BYTES", minfo.hblkhd));
686  reportData.push_back(mallOutput("HEAP_MAPPED_N_CHUNKS", minfo.hblks));
687  reportData.push_back(mallOutput("HEAP_USED_BYTES", minfo.uordblks));
688  reportData.push_back(mallOutput("HEAP_UNUSED_BYTES", minfo.fordblks));
689 
690  // Report Growth rates for VSize and Rss
691  reportData.insert(std::make_pair("AverageGrowthRateVsize",
693  reportData.insert(std::make_pair("PeakValueVsize", d2str(eventT1_.vsize)));
694  reportData.insert(
695  std::make_pair("AverageGrowthRateRss", d2str(averageGrowthRate(current_->rss, growthRateRss_, count_))));
696  reportData.insert(std::make_pair("PeakValueRss", d2str(eventRssT1_.rss)));
697 
698  reportSvc->reportMemoryInfo(reportData);
699  // This is a form of reportMemoryInfo taking s vector, not a map
700 #endif
701  } // postEndJob
static std::string i2str(int i)
std::string eventStatOutput(std::string title, SignificantEvent const &e) const
edm::propagate_const< ProcInfo * > current_
char const * label
static std::string d2str(double d)
std::string mallOutput(std::string title, size_t const &n) const
double averageGrowthRate(double current, double past, int count)
void edm::service::SimpleMemoryCheck::postEvent ( StreamContext const &  iContext)

Definition at line 703 of file SimpleMemoryCheck.cc.

References andPrint(), count_, currentSmaps_, edm::StreamContext::eventID(), fetchSmaps(), measurementUnderway_, monitorPssAndPrivate_, oncePerEventMode_, update(), updateEventStats(), and updateMax().

Referenced by SimpleMemoryCheck().

703  {
704  ++count_;
705  bool expected = false;
706  if (measurementUnderway_.compare_exchange_strong(expected, true, std::memory_order_acq_rel)) {
707  std::shared_ptr<void> guard(
708  nullptr, [this](void const*) { measurementUnderway_.store(false, std::memory_order_release); });
709  update();
710  if (monitorPssAndPrivate_) {
712  }
713  updateEventStats(iContext.eventID());
714  if (oncePerEventMode_) {
715  // should probably use be Run:Event or count_ for the label and name
716  updateMax();
717  andPrint("event", "", "");
718  }
719  }
720  }
std::atomic< bool > measurementUnderway_
void updateEventStats(edm::EventID const &e)
void andPrint(const std::string &type, const std::string &mdlabel, const std::string &mdname) const
void edm::service::SimpleMemoryCheck::postModule ( StreamContext const &  iStreamContext,
ModuleCallingContext const &  iModuleContext 
)

Definition at line 738 of file SimpleMemoryCheck.cc.

References current_, edm::StreamContext::eventID(), edm::ModuleDescription::id(), label, measurementUnderway_, edm::ModuleCallingContext::moduleDescription(), moduleEntryVsize_, moduleID_, edm::ModuleDescription::moduleLabel(), moduleMeasurementUnderway_, modules_, moduleStreamID_, moduleSummaryRequested_, oncePerEventMode_, edm::StreamContext::streamID(), AlCaHLTBitMon_QueryRunRegistry::string, update(), updateAndPrint(), updateModuleMemoryStats(), and edm::StreamID::value().

Referenced by SimpleMemoryCheck().

739  {
740  if (!oncePerEventMode_) {
741  bool expected = false;
742  if (measurementUnderway_.compare_exchange_strong(expected, true, std::memory_order_acq_rel)) {
743  std::shared_ptr<void> guard(
744  nullptr, [this](void const*) { measurementUnderway_.store(false, std::memory_order_release); });
745  auto const md = iModuleContext.moduleDescription();
746  updateAndPrint("module", md->moduleLabel(), md->moduleName());
747  }
748  }
749 
751  //is this the module instance we are measuring?
752  if (moduleMeasurementUnderway_.load(std::memory_order_acquire) and
753  (iStreamContext.streamID().value() == moduleStreamID_.load(std::memory_order_acquire)) and
754  (iModuleContext.moduleDescription()->id() == moduleID_.load(std::memory_order_acquire))) {
755  //Need to release our module measurement lock
756  std::shared_ptr<void> guard(
757  nullptr, [this](void const*) { moduleMeasurementUnderway_.store(false, std::memory_order_release); });
758  bool expected = false;
759  if (measurementUnderway_.compare_exchange_strong(expected, true, std::memory_order_acq_rel)) {
760  std::shared_ptr<void> guard(
761  nullptr, [this](void const*) { measurementUnderway_.store(false, std::memory_order_release); });
762  if (oncePerEventMode_) {
763  update();
764  }
765  // changelog 2
766  double dv = current_->vsize - moduleEntryVsize_;
767  std::string label = iModuleContext.moduleDescription()->moduleLabel();
768  updateModuleMemoryStats(modules_[label], dv, iStreamContext.eventID());
769  }
770  }
771  }
772  }
edm::propagate_const< ProcInfo * > current_
std::atomic< bool > measurementUnderway_
std::atomic< bool > moduleMeasurementUnderway_
std::atomic< unsigned int > moduleStreamID_
char const * label
void updateAndPrint(const std::string &type, const std::string &mdlabel, const std::string &mdname)
void updateModuleMemoryStats(SignificantModule &m, double dv, edm::EventID const &)
std::atomic< unsigned int > moduleID_
void edm::service::SimpleMemoryCheck::postModuleBeginJob ( const ModuleDescription )

Definition at line 497 of file SimpleMemoryCheck.cc.

References measurementUnderway_, edm::ModuleDescription::moduleLabel(), edm::ModuleDescription::moduleName(), and updateAndPrint().

Referenced by SimpleMemoryCheck().

497  {
498  bool expected = false;
499  if (measurementUnderway_.compare_exchange_strong(expected, true, std::memory_order_acq_rel)) {
500  std::shared_ptr<void> guard(
501  nullptr, [this](void const*) { measurementUnderway_.store(false, std::memory_order_release); });
502  updateAndPrint("beginJob", md.moduleLabel(), md.moduleName());
503  }
504  }
std::atomic< bool > measurementUnderway_
void updateAndPrint(const std::string &type, const std::string &mdlabel, const std::string &mdname)
void edm::service::SimpleMemoryCheck::postModuleConstruction ( const ModuleDescription )

Definition at line 488 of file SimpleMemoryCheck.cc.

References measurementUnderway_, edm::ModuleDescription::moduleLabel(), edm::ModuleDescription::moduleName(), and updateAndPrint().

Referenced by SimpleMemoryCheck().

488  {
489  bool expected = false;
490  if (measurementUnderway_.compare_exchange_strong(expected, true, std::memory_order_acq_rel)) {
491  std::shared_ptr<void> guard(
492  nullptr, [this](void const*) { measurementUnderway_.store(false, std::memory_order_release); });
493  updateAndPrint("ctor", md.moduleLabel(), md.moduleName());
494  }
495  }
std::atomic< bool > measurementUnderway_
void updateAndPrint(const std::string &type, const std::string &mdlabel, const std::string &mdname)
void edm::service::SimpleMemoryCheck::postSourceConstruction ( const ModuleDescription )

Definition at line 470 of file SimpleMemoryCheck.cc.

References measurementUnderway_, edm::ModuleDescription::moduleLabel(), edm::ModuleDescription::moduleName(), and updateAndPrint().

Referenced by SimpleMemoryCheck().

470  {
471  bool expected = false;
472  if (measurementUnderway_.compare_exchange_strong(expected, true, std::memory_order_acq_rel)) {
473  std::shared_ptr<void> guard(
474  nullptr, [this](void const*) { measurementUnderway_.store(false, std::memory_order_release); });
475  updateAndPrint("ctor", md.moduleLabel(), md.moduleName());
476  }
477  }
std::atomic< bool > measurementUnderway_
void updateAndPrint(const std::string &type, const std::string &mdlabel, const std::string &mdname)
void edm::service::SimpleMemoryCheck::postSourceEvent ( StreamID  sid)

Definition at line 479 of file SimpleMemoryCheck.cc.

References measurementUnderway_, and updateAndPrint().

Referenced by SimpleMemoryCheck().

479  {
480  bool expected = false;
481  if (measurementUnderway_.compare_exchange_strong(expected, true, std::memory_order_acq_rel)) {
482  std::shared_ptr<void> guard(
483  nullptr, [this](void const*) { measurementUnderway_.store(false, std::memory_order_release); });
484  updateAndPrint("module", "source", "source");
485  }
486  }
std::atomic< bool > measurementUnderway_
void updateAndPrint(const std::string &type, const std::string &mdlabel, const std::string &mdname)
void edm::service::SimpleMemoryCheck::preModule ( StreamContext const &  iStreamContext,
ModuleCallingContext const &  iModuleContext 
)

Definition at line 722 of file SimpleMemoryCheck.cc.

References current_, edm::ModuleDescription::id(), measurementUnderway_, edm::ModuleCallingContext::moduleDescription(), moduleEntryVsize_, moduleID_, moduleMeasurementUnderway_, moduleStreamID_, edm::StreamContext::streamID(), update(), and edm::StreamID::value().

Referenced by SimpleMemoryCheck().

722  {
723  bool expected = false;
724  if (measurementUnderway_.compare_exchange_strong(expected, true, std::memory_order_acq_rel)) {
725  std::shared_ptr<void> guard(
726  nullptr, [this](void const*) { measurementUnderway_.store(false, std::memory_order_release); });
727  bool expected = false;
728  if (moduleMeasurementUnderway_.compare_exchange_strong(expected, true)) {
729  update();
730  // changelog 2
731  moduleEntryVsize_ = current_->vsize;
732  moduleStreamID_.store(iStreamContext.streamID().value(), std::memory_order_release);
733  moduleID_.store(iModuleContext.moduleDescription()->id(), std::memory_order_release);
734  }
735  }
736  }
edm::propagate_const< ProcInfo * > current_
std::atomic< bool > measurementUnderway_
std::atomic< bool > moduleMeasurementUnderway_
std::atomic< unsigned int > moduleStreamID_
std::atomic< unsigned int > moduleID_
void edm::service::SimpleMemoryCheck::preSourceConstruction ( const ModuleDescription )

Definition at line 461 of file SimpleMemoryCheck.cc.

References measurementUnderway_, edm::ModuleDescription::moduleLabel(), edm::ModuleDescription::moduleName(), and updateAndPrint().

Referenced by SimpleMemoryCheck().

461  {
462  bool expected = false;
463  if (measurementUnderway_.compare_exchange_strong(expected, true, std::memory_order_acq_rel)) {
464  std::shared_ptr<void> guard(
465  nullptr, [this](void const*) { measurementUnderway_.store(false, std::memory_order_release); });
466  updateAndPrint("pre-ctor", md.moduleLabel(), md.moduleName());
467  }
468  }
std::atomic< bool > measurementUnderway_
void updateAndPrint(const std::string &type, const std::string &mdlabel, const std::string &mdname)
char const* edm::service::SimpleMemoryCheck::smapsLineBuffer ( ) const
inlineprivate

Definition at line 111 of file SimpleMemoryCheck.cc.

References edm::get_underlying_safe().

std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
edm::propagate_const< char * > smapsLineBuffer_
char*& edm::service::SimpleMemoryCheck::smapsLineBuffer ( )
inlineprivate

Definition at line 112 of file SimpleMemoryCheck.cc.

References edm::get_underlying_safe().

std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
edm::propagate_const< char * > smapsLineBuffer_
void edm::service::SimpleMemoryCheck::update ( )
private

Definition at line 774 of file SimpleMemoryCheck.cc.

References current_, fetch(), previous_, and std::swap().

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), MatrixUtil.Steps::overwrite(), postEvent(), postModule(), preModule(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), updateAndPrint(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

774  {
776  *current_ = fetch();
777  }
edm::propagate_const< ProcInfo * > current_
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
edm::propagate_const< ProcInfo * > previous_
void edm::service::SimpleMemoryCheck::updateAndPrint ( const std::string &  type,
const std::string &  mdlabel,
const std::string &  mdname 
)
private

Definition at line 893 of file SimpleMemoryCheck.cc.

References andPrint(), update(), and updateMax().

Referenced by postModule(), postModuleBeginJob(), postModuleConstruction(), postSourceConstruction(), postSourceEvent(), and preSourceConstruction().

895  {
896  update();
897  andPrint(type, mdlabel, mdname);
898  updateMax();
899  }
type
Definition: HCALResponse.h:21
void andPrint(const std::string &type, const std::string &mdlabel, const std::string &mdname) const
void edm::service::SimpleMemoryCheck::updateEventStats ( edm::EventID const &  e)
private

Definition at line 787 of file SimpleMemoryCheck.cc.

References count_, current_, edm::service::SimpleMemoryCheck::SignificantEvent::deltaRss, edm::service::SimpleMemoryCheck::SignificantEvent::deltaVsize, eventDeltaRssT1_, eventDeltaRssT2_, eventDeltaRssT3_, eventL1_, eventL2_, eventM_, eventR1_, eventR2_, eventRssT1_, eventRssT2_, eventRssT3_, eventT1_, eventT2_, eventT3_, num_to_skip_, edm::service::SimpleMemoryCheck::SignificantEvent::rss, edm::service::SimpleMemoryCheck::SignificantEvent::set(), SignificantEvent, and edm::service::SimpleMemoryCheck::SignificantEvent::vsize.

Referenced by postEvent().

787  {
788  if (count_ < num_to_skip_)
789  return;
790  if (count_ == num_to_skip_) {
791  eventT1_.set(0, 0, e, this);
792  eventM_.set(0, 0, e, this);
793  eventRssT1_.set(0, 0, e, this);
794  eventDeltaRssT1_.set(0, 0, e, this);
795  return;
796  }
797  double vsize = current_->vsize;
798  double deltaVsize = vsize - eventT1_.vsize;
799 
800  // Update significative events for Vsize
801  if (vsize > eventT1_.vsize) {
802  double deltaRss = current_->rss - eventT1_.rss;
803  eventT3_ = eventT2_;
804  eventT2_ = eventT1_;
805  eventT1_.set(deltaVsize, deltaRss, e, this);
806  } else if (vsize > eventT2_.vsize) {
807  double deltaRss = current_->rss - eventT1_.rss;
808  eventT3_ = eventT2_;
809  eventT2_.set(deltaVsize, deltaRss, e, this);
810  } else if (vsize > eventT3_.vsize) {
811  double deltaRss = current_->rss - eventT1_.rss;
812  eventT3_.set(deltaVsize, deltaRss, e, this);
813  }
814 
815  if (deltaVsize > eventM_.deltaVsize) {
816  double deltaRss = current_->rss - eventM_.rss;
818  eventL2_ = eventL1_;
819  } else {
820  eventL2_ = eventR1_;
821  }
822  eventL1_ = eventM_;
823  eventM_.set(deltaVsize, deltaRss, e, this);
826  } else if (deltaVsize > eventR1_.deltaVsize) {
827  double deltaRss = current_->rss - eventM_.rss;
828  eventR2_ = eventR1_;
829  eventR1_.set(deltaVsize, deltaRss, e, this);
830  } else if (deltaVsize > eventR2_.deltaVsize) {
831  double deltaRss = current_->rss - eventR1_.rss;
832  eventR2_.set(deltaVsize, deltaRss, e, this);
833  }
834 
835  // Update significative events for Rss
836  double rss = current_->rss;
837  double deltaRss = rss - eventRssT1_.rss;
838 
839  if (rss > eventRssT1_.rss) {
842  eventRssT1_.set(deltaVsize, deltaRss, e, this);
843  } else if (rss > eventRssT2_.rss) {
845  eventRssT2_.set(deltaVsize, deltaRss, e, this);
846  } else if (rss > eventRssT3_.rss) {
847  eventRssT3_.set(deltaVsize, deltaRss, e, this);
848  }
849  if (deltaRss > eventDeltaRssT1_.deltaRss) {
852  eventDeltaRssT1_.set(deltaVsize, deltaRss, e, this);
853  } else if (deltaRss > eventDeltaRssT2_.deltaRss) {
855  eventDeltaRssT2_.set(deltaVsize, deltaRss, e, this);
856  } else if (deltaRss > eventDeltaRssT3_.deltaRss) {
857  eventDeltaRssT3_.set(deltaVsize, deltaRss, e, this);
858  }
859  } // updateEventStats
edm::propagate_const< ProcInfo * > current_
void set(double deltaV, double deltaR, edm::EventID const &e, SimpleMemoryCheck *t)
void edm::service::SimpleMemoryCheck::updateMax ( )
private

Definition at line 779 of file SimpleMemoryCheck.cc.

References count_, current_, max_, num_to_skip_, and oncePerEventMode_.

Referenced by postEvent(), and updateAndPrint().

779  {
780  if ((*current_ > max_) || oncePerEventMode_) {
781  if (count_ >= num_to_skip_) {
782  }
783  max_ = *current_;
784  }
785  }
edm::propagate_const< ProcInfo * > current_
void edm::service::SimpleMemoryCheck::updateModuleMemoryStats ( SignificantModule m,
double  dv,
edm::EventID const &  currentEventID 
)
private

Definition at line 970 of file SimpleMemoryCheck.cc.

References count_, edm::service::SimpleMemoryCheck::SignificantModule::eventMaxDeltaV, edm::service::SimpleMemoryCheck::SignificantModule::maxDeltaVsize, edm::service::SimpleMemoryCheck::SignificantModule::maxEarlyVsize, num_to_skip_, edm::service::SimpleMemoryCheck::SignificantModule::postEarlyCount, edm::service::SimpleMemoryCheck::SignificantModule::totalDeltaVsize, and edm::service::SimpleMemoryCheck::SignificantModule::totalEarlyVsize.

Referenced by postModule().

972  {
973  if (count_ < num_to_skip_) {
974  m.totalEarlyVsize += dv;
975  if (dv > m.maxEarlyVsize)
976  m.maxEarlyVsize = dv;
977  } else {
978  ++m.postEarlyCount;
979  m.totalDeltaVsize += dv;
980  if (dv > m.maxDeltaVsize) {
981  m.maxDeltaVsize = dv;
982  m.eventMaxDeltaV = currentEventID;
983  }
984  }
985  } //updateModuleMemoryStats

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
SimpleMemoryCheck::SignificantEvent const &  se 
)
friend

Definition at line 987 of file SimpleMemoryCheck.cc.

987  {
988  os << "[" << se.count << "] " << se.event << " vsize = " << se.vsize << " deltaVsize = " << se.deltaVsize
989  << " rss = " << se.rss << " delta = " << se.deltaRss;
990 
991  if (se.monitorPssAndPrivate) {
992  os << " private = " << se.privateSize << " pss = " << se.pss;
993  }
994  return os;
995  }
std::ostream& operator<< ( std::ostream &  os,
SimpleMemoryCheck::SignificantModule const &  se 
)
friend

Definition at line 997 of file SimpleMemoryCheck.cc.

997  {
998  if (sm.postEarlyCount > 0) {
999  os << "\nPost Early Events: TotalDeltaVsize: " << sm.totalDeltaVsize
1000  << " (avg: " << sm.totalDeltaVsize / sm.postEarlyCount << "; max: " << sm.maxDeltaVsize << " during "
1001  << sm.eventMaxDeltaV << ")";
1002  }
1003  if (sm.totalEarlyVsize > 0) {
1004  os << "\n Early Events: TotalDeltaVsize: " << sm.totalEarlyVsize << " (max: " << sm.maxEarlyVsize << ")";
1005  }
1006 
1007  return os;
1008  }
friend struct SignificantEvent
friend

Definition at line 176 of file SimpleMemoryCheck.cc.

Referenced by updateEventStats().

friend struct SignificantModule
friend

Definition at line 244 of file SimpleMemoryCheck.cc.

Member Data Documentation

ProcInfo edm::service::SimpleMemoryCheck::a_
private

Definition at line 114 of file SimpleMemoryCheck.cc.

ProcInfo edm::service::SimpleMemoryCheck::b_
private

Definition at line 115 of file SimpleMemoryCheck.cc.

std::atomic<int> edm::service::SimpleMemoryCheck::count_
private
edm::propagate_const<ProcInfo*> edm::service::SimpleMemoryCheck::current_
private
smapsInfo edm::service::SimpleMemoryCheck::currentSmaps_
private

Definition at line 120 of file SimpleMemoryCheck.cc.

Referenced by postEvent().

SignificantEvent edm::service::SimpleMemoryCheck::eventDeltaRssT1_
private

Definition at line 218 of file SimpleMemoryCheck.cc.

Referenced by postEndJob(), and updateEventStats().

SignificantEvent edm::service::SimpleMemoryCheck::eventDeltaRssT2_
private

Definition at line 219 of file SimpleMemoryCheck.cc.

Referenced by postEndJob(), and updateEventStats().

SignificantEvent edm::service::SimpleMemoryCheck::eventDeltaRssT3_
private

Definition at line 220 of file SimpleMemoryCheck.cc.

Referenced by postEndJob(), and updateEventStats().

SignificantEvent edm::service::SimpleMemoryCheck::eventL1_
private

Definition at line 195 of file SimpleMemoryCheck.cc.

Referenced by postEndJob(), and updateEventStats().

SignificantEvent edm::service::SimpleMemoryCheck::eventL2_
private

Definition at line 196 of file SimpleMemoryCheck.cc.

Referenced by postEndJob(), and updateEventStats().

SignificantEvent edm::service::SimpleMemoryCheck::eventM_
private

Definition at line 194 of file SimpleMemoryCheck.cc.

Referenced by postEndJob(), and updateEventStats().

SignificantEvent edm::service::SimpleMemoryCheck::eventR1_
private

Definition at line 197 of file SimpleMemoryCheck.cc.

Referenced by postEndJob(), and updateEventStats().

SignificantEvent edm::service::SimpleMemoryCheck::eventR2_
private

Definition at line 198 of file SimpleMemoryCheck.cc.

Referenced by postEndJob(), and updateEventStats().

SignificantEvent edm::service::SimpleMemoryCheck::eventRssT1_
private

Definition at line 215 of file SimpleMemoryCheck.cc.

Referenced by postEndJob(), and updateEventStats().

SignificantEvent edm::service::SimpleMemoryCheck::eventRssT2_
private

Definition at line 216 of file SimpleMemoryCheck.cc.

Referenced by postEndJob(), and updateEventStats().

SignificantEvent edm::service::SimpleMemoryCheck::eventRssT3_
private

Definition at line 217 of file SimpleMemoryCheck.cc.

Referenced by postEndJob(), and updateEventStats().

SignificantEvent edm::service::SimpleMemoryCheck::eventT1_
private

Definition at line 199 of file SimpleMemoryCheck.cc.

Referenced by postEndJob(), and updateEventStats().

SignificantEvent edm::service::SimpleMemoryCheck::eventT2_
private

Definition at line 200 of file SimpleMemoryCheck.cc.

Referenced by postEndJob(), and updateEventStats().

SignificantEvent edm::service::SimpleMemoryCheck::eventT3_
private

Definition at line 201 of file SimpleMemoryCheck.cc.

Referenced by postEndJob(), and updateEventStats().

double edm::service::SimpleMemoryCheck::growthRateRss_
private

Definition at line 139 of file SimpleMemoryCheck.cc.

Referenced by postBeginJob(), and postEndJob().

double edm::service::SimpleMemoryCheck::growthRateVsize_
private

Definition at line 138 of file SimpleMemoryCheck.cc.

Referenced by postBeginJob(), and postEndJob().

bool edm::service::SimpleMemoryCheck::jobReportOutputOnly_
private

Definition at line 128 of file SimpleMemoryCheck.cc.

Referenced by andPrint(), and postEndJob().

ProcInfo edm::service::SimpleMemoryCheck::max_
private

Definition at line 116 of file SimpleMemoryCheck.cc.

Referenced by andPrint(), and updateMax().

std::atomic<bool> edm::service::SimpleMemoryCheck::measurementUnderway_
private
double edm::service::SimpleMemoryCheck::moduleEntryVsize_
private

Definition at line 249 of file SimpleMemoryCheck.cc.

Referenced by postModule(), and preModule().

std::atomic<unsigned int> edm::service::SimpleMemoryCheck::moduleID_
private

Definition at line 256 of file SimpleMemoryCheck.cc.

Referenced by postModule(), and preModule().

std::atomic<bool> edm::service::SimpleMemoryCheck::moduleMeasurementUnderway_
private

Definition at line 254 of file SimpleMemoryCheck.cc.

Referenced by postModule(), and preModule().

SignificantModulesMap edm::service::SimpleMemoryCheck::modules_
private

Definition at line 248 of file SimpleMemoryCheck.cc.

Referenced by postEndJob(), and postModule().

std::atomic<unsigned int> edm::service::SimpleMemoryCheck::moduleStreamID_
private

Definition at line 255 of file SimpleMemoryCheck.cc.

Referenced by postModule(), and preModule().

bool edm::service::SimpleMemoryCheck::moduleSummaryRequested_
private

Definition at line 246 of file SimpleMemoryCheck.cc.

Referenced by postEndJob(), postModule(), and SimpleMemoryCheck().

bool edm::service::SimpleMemoryCheck::monitorPssAndPrivate_
private

Definition at line 129 of file SimpleMemoryCheck.cc.

Referenced by eventStatOutput(), openFiles(), and postEvent().

int edm::service::SimpleMemoryCheck::num_to_skip_
private
bool edm::service::SimpleMemoryCheck::oncePerEventMode_
private

Definition at line 127 of file SimpleMemoryCheck.cc.

Referenced by andPrint(), postEvent(), postModule(), SimpleMemoryCheck(), and updateMax().

double edm::service::SimpleMemoryCheck::pg_size_
private

Definition at line 123 of file SimpleMemoryCheck.cc.

ProcInfoFetcher edm::service::SimpleMemoryCheck::piFetcher_
private

Definition at line 122 of file SimpleMemoryCheck.cc.

edm::propagate_const<ProcInfo*> edm::service::SimpleMemoryCheck::previous_
private

Definition at line 118 of file SimpleMemoryCheck.cc.

Referenced by update().

bool edm::service::SimpleMemoryCheck::showMallocInfo_
private

Definition at line 126 of file SimpleMemoryCheck.cc.

Referenced by andPrint().

edm::propagate_const<FILE*> edm::service::SimpleMemoryCheck::smapsFile_
private

Definition at line 133 of file SimpleMemoryCheck.cc.

Referenced by openFiles(), and ~SimpleMemoryCheck().

edm::propagate_const<char*> edm::service::SimpleMemoryCheck::smapsLineBuffer_
private

Definition at line 134 of file SimpleMemoryCheck.cc.

Referenced by ~SimpleMemoryCheck().

size_t edm::service::SimpleMemoryCheck::smapsLineBufferLen_
private

Definition at line 135 of file SimpleMemoryCheck.cc.