CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes | Private Attributes
dqm-mbProfile.Profile Class Reference
Inheritance diagram for dqm-mbProfile.Profile:

Public Member Functions

def __init__ (self, args)
 
def finish (self)
 
def read_smaps (self, proc_dict)
 
def to_dict (self)
 
def update (self)
 
def update_proc (self)
 
def update_ru (self)
 

Public Attributes

 final
 
 known_pids
 
 pid
 
 ru
 
 ru_diff
 
 time
 

Private Attributes

 _args
 
 _file
 
 _offset_ru
 

Detailed Description

Definition at line 104 of file dqm-mbProfile.py.

Constructor & Destructor Documentation

def dqm-mbProfile.Profile.__init__ (   self,
  args 
)

Definition at line 105 of file dqm-mbProfile.py.

105  def __init__(self, args):
106  self.time = time.time()
107  self.final = False
108  self.pid = None
109  self.known_pids = {}
110 
111  self.ru = {}
112  self.ru_diff = {}
113 
114  self._offset_ru = None
115  self._args = args
116 
117  if self._args.file:
118  self._file = open(self._args.file, "w")
119  else:
120  self._file = None
121 
122  self.update()
123 
def __init__(self, args)

Member Function Documentation

def dqm-mbProfile.Profile.finish (   self)

Definition at line 209 of file dqm-mbProfile.py.

References CommonAnalyzer._file, dqm-mbProfile.Profile._file, dqm-mbProfile.Profile.final, dqm-mbProfile.Profile.ru_diff, FastFedCablingTask.update(), ErrorCorrelation.update(), ApvTimingTask.update(), DaqScopeModeTask.update(), FedTimingTask.update(), VpspScanTask.update(), NoiseHistosUsingDb.update(), OptoScanHistosUsingDb.update(), PedestalsHistosUsingDb.update(), PedsFullNoiseHistosUsingDb.update(), PedsOnlyHistosUsingDb.update(), VpspScanHistosUsingDb.update(), AlignableDet.update(), OptoScanTask.update(), PedestalsTask.update(), ApvTimingHistosUsingDb.update(), CalibrationScanTask.update(), CalibrationTask.update(), FineDelayTask.update(), LatencyTask.update(), cond::persistency::ITagTable.update(), edm::SubProcessParentageHelper.update(), FastFedCablingHistosUsingDb.update(), AlignableDetUnit.update(), SamplingHistosUsingDb.update(), FedCablingTask.update(), LatencyHistosUsingDb.update(), NoiseTask.update(), PedsOnlyTask.update(), CalibrationHistosUsingDb.update(), FineDelayHistosUsingDb.update(), PedsFullNoiseTask.update(), AlignableCSCChamber.update(), cond::persistency::GLOBAL_TAG::Table.update(), BinomialProbability.update(), GraphPath< N, E >.update(), AlignableTracker.update(), cond::persistency::TAG::Table.update(), AlignableComposite.update(), pos::PixelConfig.update(), HcaluLUTTPGCoder.update(), SiStripConfObject.update(), AlignableMuon.update(), Alignable.update(), LaserAlignmentSimulation.update(), ApvAnalysisFactory.update(), DTVDriftCalibration::cellInfo.update(), cond::persistency::IPayloadMigrationTable.update(), HLTScalersClient::CountLSFifo_t.update(), cond::persistency::IGTTable.update(), DTRecSegment2D.update(), DQMNet::Peer.update, CommissioningTask.update(), DQMNet::AutoPeer.update, dqm-mbProfile.Profile.update(), and edmNew::DetSetVector< T >.update().

Referenced by progressbar.ProgressBar.__next__().

209  def finish(self):
210  self.final = True
211  self.update()
212 
213  if self._file:
214  self._file.close()
215  self._file = None
216  else:
217  log.info("ru_diff: %s", self.ru_diff)
218 
219 
def dqm-mbProfile.Profile.read_smaps (   self,
  proc_dict 
)

Definition at line 143 of file dqm-mbProfile.py.

References createfilelist.int.

Referenced by dqm-mbProfile.Profile.update_proc().

143  def read_smaps(self, proc_dict):
144  Private, Shared, Pss = 0, 0, 0
145 
146  fp = os.path.join("/proc/%d" % proc_dict["pid"], "smaps")
147  with open(fp) as fd:
148  for line in fd.readlines():
149  if line.startswith("Shared"):
150  Shared += int(line.split()[1])
151  elif line.startswith("Private"):
152  Private += int(line.split()[1])
153  elif line.startswith("Pss"):
154  Pss += int(line.split()[1])
155 
156  proc_dict["smaps_shared"] = Shared * 1024
157  proc_dict["smaps_private"] = Private * 1024
158  proc_dict["smaps_pss"] = Pss * 1024
159 
def read_smaps(self, proc_dict)
def dqm-mbProfile.Profile.to_dict (   self)

Definition at line 198 of file dqm-mbProfile.py.

References cmsPerfStripChart.dict, dqm-mbProfile.Profile.final, dqm-mbProfile.Profile.known_pids, dqm-mbProfile.Profile.pid, dqm-mbProfile.Profile.ru, dqm-mbProfile.Profile.ru_diff, RPCStripNoises::NoiseItem.time, RPCObImon::I_Item.time, RPCObGas::Item.time, RecoObj.time, RPCObFebmap::Feb_Item.time, RPCObVmon::V_Item.time, popcon::PopConSourceHandler< T >::Triplet.time, classes.PedeDumpData.time, RPCObStatus::S_Item.time, DTTMax::InfoLayer.time, RPCObTemp::T_Item.time, CTPPSLocalTrackLite.time, and dqm-mbProfile.Profile.time.

Referenced by dqm-mbProfile.Profile.update().

198  def to_dict(self):
199  dct = collections.OrderedDict()
200  dct['time'] = self.time
201  dct['pid'] = self.pid
202  dct['final'] = self.final
203 
204  dct['ru_diff'] = dict(self.ru_diff)
205  dct['ru'] = dict((k, v) for k, v in inspect.getmembers(self.ru) if k.startswith('ru_'))
206  dct['known_pids'] = dict(self.known_pids)
207  return dct
208 
def dqm-mbProfile.Profile.update (   self)

Definition at line 185 of file dqm-mbProfile.py.

References CommonAnalyzer._file, dqm-mbProfile.Profile._file, RPCStripNoises::NoiseItem.time, RPCObImon::I_Item.time, RPCObGas::Item.time, RecoObj.time, RPCObFebmap::Feb_Item.time, RPCObVmon::V_Item.time, popcon::PopConSourceHandler< T >::Triplet.time, classes.PedeDumpData.time, RPCObStatus::S_Item.time, DTTMax::InfoLayer.time, RPCObTemp::T_Item.time, CTPPSLocalTrackLite.time, dqm-mbProfile.Profile.time, dqm-mbProfile.Profile.to_dict(), dqm-mbProfile.Profile.update_proc(), and dqm-mbProfile.Profile.update_ru().

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(), dqm-mbProfile.Profile.finish(), 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(), 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(), and Vispa.Gui.PortConnection.PointToPointConnection.updateConnection().

185  def update(self):
186  self.time = time.time()
187 
188  self.update_ru()
189  self.update_proc()
190 
191  if self._file:
192  json.dump(self.to_dict(), self._file)
193  self._file.write("\n")
194  self._file.flush()
195 
196  log.info("Written profile to: %s, took=%.03f", self._args.file, time.time() - self.time)
197 
def dqm-mbProfile.Profile.update_proc (   self)

Definition at line 160 of file dqm-mbProfile.py.

References dqm-mbProfile.get_children(), dqm-mbProfile.Profile.known_pids, and dqm-mbProfile.Profile.read_smaps().

Referenced by dqm-mbProfile.Profile.update().

160  def update_proc(self):
161  procs = get_children(os.getpid())
162 
163  # we can only do it here, permision-wise
164  # ie only for owned processes
165  for proc in procs:
166  try:
167  self.read_smaps(proc)
168  except:
169  log.warning("Exception in read_smaps.", exc_info=True)
170 
171  # we need to mark not-running ones as such
172  stopped = set(self.known_pids.keys())
173  for proc in procs:
174  proc["running"] = True
175 
176  pid = proc["pid"]
177  self.known_pids[pid] = proc
178 
179  if pid in stopped:
180  stopped.remove(pid)
181 
182  for pid in stopped:
183  self.known_pids[pid]["running"] = False
184 
def get_children(ppid)
def read_smaps(self, proc_dict)
def dqm-mbProfile.Profile.update_ru (   self)

Definition at line 124 of file dqm-mbProfile.py.

References dqm-mbProfile.Profile._offset_ru, dqm-mbProfile.Profile.ru, and dqm-mbProfile.Profile.ru_diff.

Referenced by dqm-mbProfile.Profile.update().

124  def update_ru(self):
125  fields_to_subtract = (
126  "ru_utime", "ru_stime", "ru_maxrss", "ru_minflt", "ru_majflt", "ru_nswap",
127  "ru_inblock", "ru_oublock", "ru_msgsnd", "ru_msgrcv", "ru_nsignals", "ru_nvcsw", "ru_nivcsw",
128  )
129 
130  rusage = resource.getrusage(resource.RUSAGE_CHILDREN)
131  self.ru = rusage
132 
133  if self._offset_ru is None:
134  self._offset_ru = rusage
135 
136  for field in fields_to_subtract:
137  current = getattr(self.ru, field)
138  base = getattr(self._offset_ru, field)
139 
140  self.ru_diff[field] = current - base
141 

Member Data Documentation

dqm-mbProfile.Profile._args
private
dqm-mbProfile.Profile._file
private
dqm-mbProfile.Profile._offset_ru
private

Definition at line 114 of file dqm-mbProfile.py.

Referenced by dqm-mbProfile.Profile.update_ru().

dqm-mbProfile.Profile.final
dqm-mbProfile.Profile.known_pids
dqm-mbProfile.Profile.pid

Definition at line 108 of file dqm-mbProfile.py.

Referenced by dqm-mbProfile.Profile.to_dict().

dqm-mbProfile.Profile.ru
dqm-mbProfile.Profile.ru_diff
dqm-mbProfile.Profile.time