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.12 2012/05/06 19:11:56 chrjones 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 
26 
27 #include <cstdio>
28 
29 namespace edm {
30  class EventID;
31  class Timestamp;
32  class Event;
33  class EventSetup;
34  class ModuleDescription;
36 
37  namespace service {
38  struct smapsInfo
39  {
41  smapsInfo(double private_sz, double pss_sz): private_(private_sz),pss_(pss_sz) {}
42 
43  bool operator==(const smapsInfo& p) const
44  { return private_==p.private_ && pss_==p.pss_; }
45 
46  bool operator>(const smapsInfo& p) const
47  { return private_>p.private_ || pss_>p.pss_; }
48 
49  double private_; // in MB
50  double pss_; // in MB
51  };
52 
53 
55  {
56  public:
57 
60 
61  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
62 
65  void postSource();
66 
67  void postBeginJob();
68 
69  void preEventProcessing(const edm::EventID&, const edm::Timestamp&);
70  void postEventProcessing(const Event&, const EventSetup&);
71 
74 
75  void preModule(const ModuleDescription&);
76  void postModule(const ModuleDescription&);
77 
78  void postEndJob();
79 
80  void postFork(unsigned int, unsigned int);
81  private:
82  ProcInfo fetch();
84  double pageSize() const { return pg_size_; }
85  double averageGrowthRate(double current, double past, int count);
86  void update();
87  void updateMax();
88  void andPrint(const std::string& type,
89  const std::string& mdlabel, const std::string& mdname) const;
90  void updateAndPrint(const std::string& type,
91  const std::string& mdlabel, const std::string& mdname);
92  void openFiles();
93 
99 
101 
103  double pg_size_;
105  //options
110  int count_;
111 
112  //smaps
113  FILE* smapsFile_;
116 
117 
118  //Rates of growth
121 
122  // Event summary statistics changeLog 1
124  int count;
125  double vsize;
126  double deltaVsize;
127  double rss;
128  double deltaRss;
130  double privateSize;
131  double pss;
135  void set (double deltaV, double deltaR,
136  edm::EventID const & e, SimpleMemoryCheck *t)
137  { count = t->count_;
138  vsize = t->current_->vsize;
139  deltaVsize = deltaV;
140  rss = t->current_->rss;
141  deltaRss = deltaR;
143  if (monitorPssAndPrivate) {
145  pss = t->currentSmaps_.pss_;
146  }
147  event = e;
148  }
149  }; // SignificantEvent
150  friend struct SignificantEvent;
151  friend std::ostream & operator<< (std::ostream & os,
153 
154  /*
155  Significative events for deltaVsize:
156  - eventM_: Event which makes the biggest value for deltaVsize
157  - eventL1_: Event which makes the second biggest value for deltaVsize
158  - eventL2_: Event which makes the third biggest value for deltaVsize
159  - eventR1_: Event which makes the second biggest value for deltaVsize
160  - eventR2_: Event which makes the third biggest value for deltaVsize
161  M>L1>L2 and M>R1>R2
162  Unknown relation between Ls and Rs events ???????
163  Significative events for vsize:
164  - eventT1_: Event whith the biggest value for vsize
165  - eventT2_: Event whith the second biggest value for vsize
166  - eventT3_: Event whith the third biggest value for vsize
167  T1>T2>T3
168  */
177 
178  /*
179  Significative event for deltaRss:
180  - eventRssT1_: Event whith the biggest value for rss
181  - eventRssT2_: Event whith the second biggest value for rss
182  - eventRssT3_: Event whith the third biggest value for rss
183  T1>T2>T3
184  Significative events for deltaRss:
185  - eventDeltaRssT1_: Event whith the biggest value for deltaRss
186  - eventDeltaRssT2_: Event whith the second biggest value for deltaRss
187  - eventDeltaRssT3_: Event whith the third biggest value for deltaRss
188  T1>T2>T3
189  */
196 
197 
198  void updateEventStats(edm::EventID const & e);
199  std::string eventStatOutput(std::string title,
200  SignificantEvent const& e) const;
201  void eventStatOutput(std::string title,
202  SignificantEvent const& e,
203  std::map<std::string, std::string> &m) const;
204  std::string mallOutput(std::string title, size_t const& n) const;
205 
206  // Module summary statistices
215  , totalDeltaVsize (0)
216  , maxDeltaVsize (0)
217  , eventMaxDeltaV ()
218  , totalEarlyVsize (0)
219  , maxEarlyVsize (0) {}
220  void set (double deltaV, bool early);
221  }; // SignificantModule
222  friend struct SignificantModule;
223  friend std::ostream & operator<< (std::ostream & os,
226  typedef std::map<std::string,SignificantModule> SignificantModulesMap;
230  void updateModuleMemoryStats(SignificantModule & m, double dv);
231 
232  }; // SimpleMemoryCheck
233 
234  std::ostream &
235  operator<< (std::ostream & os,
237 
238  std::ostream &
239  operator<< (std::ostream & os,
241 
242  }
243 }
244 
245 
246 
247 #endif
std::map< std::string, SignificantModule > SignificantModulesMap
Definition: Memory.h:226
type
Definition: HCALResponse.h:22
std::string eventStatOutput(std::string title, SignificantEvent const &e) const
void postFork(unsigned int, unsigned int)
Definition: Memory.cc:519
SignificantEvent eventDeltaRssT1_
Definition: Memory.h:193
void preSourceConstruction(const ModuleDescription &)
Definition: Memory.cc:244
std::pair< ALIstring, ALIstring > pss
Definition: Fit.h:27
friend std::ostream & operator<<(std::ostream &os, SimpleMemoryCheck::SignificantEvent const &se)
Definition: Memory.cc:733
edm::EventID currentEventID_
Definition: Memory.h:229
SignificantEvent eventM_
Definition: Memory.h:169
SignificantEvent eventT1_
Definition: Memory.h:174
void updateEventStats(edm::EventID const &e)
Definition: Memory.cc:541
ProcInfoFetcher piFetcher_
Definition: Memory.h:102
void postModule(const ModuleDescription &)
Definition: Memory.cc:506
SignificantEvent eventRssT2_
Definition: Memory.h:191
SignificantEvent eventL1_
Definition: Memory.h:170
SignificantEvent eventT3_
Definition: Memory.h:176
void andPrint(const std::string &type, const std::string &mdlabel, const std::string &mdname) const
Definition: Memory.cc:614
SignificantEvent eventRssT3_
Definition: Memory.h:192
void preModule(const ModuleDescription &)
Definition: Memory.cc:501
void set(double deltaV, double deltaR, edm::EventID const &e, SimpleMemoryCheck *t)
Definition: Memory.h:135
void postEventProcessing(const Event &, const EventSetup &)
Definition: Memory.cc:487
void updateModuleMemoryStats(SignificantModule &m, double dv)
Definition: Memory.cc:717
ErrorLog & operator<<(ErrorLog &e, const T &t)
SignificantEvent eventR1_
Definition: Memory.h:172
SignificantEvent eventDeltaRssT3_
Definition: Memory.h:195
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
smapsInfo(double private_sz, double pss_sz)
Definition: Memory.h:41
void updateAndPrint(const std::string &type, const std::string &mdlabel, const std::string &mdname)
Definition: Memory.cc:651
bool operator==(const smapsInfo &p) const
Definition: Memory.h:43
SignificantEvent eventR2_
Definition: Memory.h:173
SignificantEvent eventL2_
Definition: Memory.h:171
SignificantEvent eventDeltaRssT2_
Definition: Memory.h:194
std::string mallOutput(std::string title, size_t const &n) const
void postSourceConstruction(const ModuleDescription &)
Definition: Memory.cc:249
SignificantEvent eventT2_
Definition: Memory.h:175
void postModuleBeginJob(const ModuleDescription &)
Definition: Memory.cc:261
double averageGrowthRate(double current, double past, int count)
Definition: Memory.cc:109
void preEventProcessing(const edm::EventID &, const edm::Timestamp &)
Definition: Memory.cc:483
SimpleMemoryCheck(const ParameterSet &, ActivityRegistry &)
Definition: Memory.cc:113
SignificantModulesMap modules_
Definition: Memory.h:227
SignificantEvent eventRssT1_
Definition: Memory.h:190
void postModuleConstruction(const ModuleDescription &)
Definition: Memory.cc:257
bool operator>(const smapsInfo &p) const
Definition: Memory.h:46
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: Memory.cc:211
double pageSize() const
Definition: Memory.h:84