CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Memory.h
Go to the documentation of this file.
1 #ifndef FWCore_Services_Memory_h
2 #define FWCore_Services_Memory_h
3 // -*- C++ -*-
4 //
5 // Package: Services
6 // Class : SimpleMemoryCheck
7 //
8 //
9 // Original Author: Jim Kowalkowski
10 // $Id: Memory.h,v 1.8 2010/03/09 16:24:57 wdd Exp $
11 //
12 // Change Log
13 //
14 // 1 - Apr 25, 2008 M. Fischler
15 // Data structures for Event summary statistics,
16 //
17 // 2 - Jan 14, 2009 Natalia Garcia Nebot
18 // Added: - Average rate of growth in RSS and peak value attained.
19 // - Average rate of growth in VSize over time, Peak VSize
20 
21 
25 
26 namespace edm {
27  class EventID;
28  class Timestamp;
29  class Event;
30  class EventSetup;
31  class ModuleDescription;
33 
34  namespace service {
35  struct procInfo
36  {
37  procInfo():vsize(),rss() {}
38  procInfo(double sz, double rss_sz): vsize(sz),rss(rss_sz) {}
39 
40  bool operator==(const procInfo& p) const
41  { return vsize==p.vsize && rss==p.rss; }
42 
43  bool operator>(const procInfo& p) const
44  { return vsize>p.vsize || rss>p.rss; }
45 
46  // see proc(4) man pages for units and a description
47  double vsize; // in MB (used to be in pages?)
48  double rss; // in MB (used to be in pages?)
49  };
50 
52  {
53  public:
54 
57 
58  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
59 
62  void postSource();
63 
64  void postBeginJob();
65 
66  void preEventProcessing(const edm::EventID&, const edm::Timestamp&);
67  void postEventProcessing(const Event&, const EventSetup&);
68 
71 
72  void preModule(const ModuleDescription&);
73  void postModule(const ModuleDescription&);
74 
75  void postEndJob();
76 
77  private:
78  procInfo fetch();
79  double pageSize() const { return pg_size_; }
80  double averageGrowthRate(double current, double past, int count);
81  void update();
82  void updateMax();
83  void andPrint(const std::string& type,
84  const std::string& mdlabel, const std::string& mdname) const;
85  void updateAndPrint(const std::string& type,
86  const std::string& mdlabel, const std::string& mdname);
87 
93 
94  char buf_[500];
95  int fd_;
96  std::string fname_;
97  double pg_size_;
99  //options
103  int count_;
104 
105  //Rates of growth
108 
109  // Event summary statistics changeLog 1
111  int count;
112  double vsize;
113  double deltaVsize;
114  double rss;
115  double deltaRss;
118  rss(0), deltaRss(0), event() {}
119  void set (double deltaV, double deltaR,
120  edm::EventID const & e, SimpleMemoryCheck *t)
121  { count = t->count_;
122  vsize = t->current_->vsize;
123  deltaVsize = deltaV;
124  rss = t->current_->rss;
125  deltaRss = deltaR;
126  event = e;
127  }
128  }; // SignificantEvent
129  friend struct SignificantEvent;
130  friend std::ostream & operator<< (std::ostream & os,
132 
133  /*
134  Significative events for deltaVsize:
135  - eventM_: Event which makes the biggest value for deltaVsize
136  - eventL1_: Event which makes the second biggest value for deltaVsize
137  - eventL2_: Event which makes the third biggest value for deltaVsize
138  - eventR1_: Event which makes the second biggest value for deltaVsize
139  - eventR2_: Event which makes the third biggest value for deltaVsize
140  M>L1>L2 and M>R1>R2
141  Unknown relation between Ls and Rs events ???????
142  Significative events for vsize:
143  - eventT1_: Event whith the biggest value for vsize
144  - eventT2_: Event whith the second biggest value for vsize
145  - eventT3_: Event whith the third biggest value for vsize
146  T1>T2>T3
147  */
156 
157  /*
158  Significative event for deltaRss:
159  - eventRssT1_: Event whith the biggest value for rss
160  - eventRssT2_: Event whith the second biggest value for rss
161  - eventRssT3_: Event whith the third biggest value for rss
162  T1>T2>T3
163  Significative events for deltaRss:
164  - eventDeltaRssT1_: Event whith the biggest value for deltaRss
165  - eventDeltaRssT2_: Event whith the second biggest value for deltaRss
166  - eventDeltaRssT3_: Event whith the third biggest value for deltaRss
167  T1>T2>T3
168  */
175 
176 
177  void updateEventStats(edm::EventID const & e);
178  std::string eventStatOutput(std::string title,
179  SignificantEvent const& e) const;
180  void eventStatOutput(std::string title,
181  SignificantEvent const& e,
182  std::map<std::string, std::string> &m) const;
183  std::string mallOutput(std::string title, size_t const& n) const;
184 
185  // Module summary statistices
194  , totalDeltaVsize (0)
195  , maxDeltaVsize (0)
196  , eventMaxDeltaV ()
197  , totalEarlyVsize (0)
198  , maxEarlyVsize (0) {}
199  void set (double deltaV, bool early);
200  }; // SignificantModule
201  friend struct SignificantModule;
202  friend std::ostream & operator<< (std::ostream & os,
205  typedef std::map<std::string,SignificantModule> SignificantModulesMap;
209  void updateModuleMemoryStats(SignificantModule & m, double dv);
210 
211  }; // SimpleMemoryCheck
212 
213  std::ostream &
214  operator<< (std::ostream & os,
216 
217  std::ostream &
218  operator<< (std::ostream & os,
220 
221  }
222 }
223 
224 
225 
226 #endif
std::map< std::string, SignificantModule > SignificantModulesMap
Definition: Memory.h:205
type
Definition: HCALResponse.h:22
std::string eventStatOutput(std::string title, SignificantEvent const &e) const
SignificantEvent eventDeltaRssT1_
Definition: Memory.h:172
void preSourceConstruction(const ModuleDescription &)
Definition: Memory.cc:322
friend std::ostream & operator<<(std::ostream &os, SimpleMemoryCheck::SignificantEvent const &se)
Definition: Memory.cc:816
bool operator==(const procInfo &p) const
Definition: Memory.h:40
edm::EventID currentEventID_
Definition: Memory.h:208
SignificantEvent eventM_
Definition: Memory.h:148
SignificantEvent eventT1_
Definition: Memory.h:153
void updateEventStats(edm::EventID const &e)
Definition: Memory.cc:625
void postModule(const ModuleDescription &)
Definition: Memory.cc:595
procInfo(double sz, double rss_sz)
Definition: Memory.h:38
SignificantEvent eventRssT2_
Definition: Memory.h:170
SignificantEvent eventL1_
Definition: Memory.h:149
SignificantEvent eventT3_
Definition: Memory.h:155
void andPrint(const std::string &type, const std::string &mdlabel, const std::string &mdname) const
Definition: Memory.cc:698
SignificantEvent eventRssT3_
Definition: Memory.h:171
bool operator>(const procInfo &p) const
Definition: Memory.h:43
void preModule(const ModuleDescription &)
Definition: Memory.cc:590
void set(double deltaV, double deltaR, edm::EventID const &e, SimpleMemoryCheck *t)
Definition: Memory.h:119
void postEventProcessing(const Event &, const EventSetup &)
Definition: Memory.cc:577
void updateModuleMemoryStats(SignificantModule &m, double dv)
Definition: Memory.cc:798
ErrorLog & operator<<(ErrorLog &e, const T &t)
SignificantEvent eventR1_
Definition: Memory.h:151
SignificantEvent eventDeltaRssT3_
Definition: Memory.h:174
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
void updateAndPrint(const std::string &type, const std::string &mdlabel, const std::string &mdname)
Definition: Memory.cc:736
SignificantEvent eventR2_
Definition: Memory.h:152
SignificantEvent eventL2_
Definition: Memory.h:150
SignificantEvent eventDeltaRssT2_
Definition: Memory.h:173
std::string mallOutput(std::string title, size_t const &n) const
void postSourceConstruction(const ModuleDescription &)
Definition: Memory.cc:328
SignificantEvent eventT2_
Definition: Memory.h:154
void postModuleBeginJob(const ModuleDescription &)
Definition: Memory.cc:343
double averageGrowthRate(double current, double past, int count)
Definition: Memory.cc:182
void preEventProcessing(const edm::EventID &, const edm::Timestamp &)
Definition: Memory.cc:571
SimpleMemoryCheck(const ParameterSet &, ActivityRegistry &)
Definition: Memory.cc:186
SignificantModulesMap modules_
Definition: Memory.h:206
SignificantEvent eventRssT1_
Definition: Memory.h:169
void postModuleConstruction(const ModuleDescription &)
Definition: Memory.cc:338
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: Memory.cc:301
double pageSize() const
Definition: Memory.h:79