CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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__
 
def finish
 
def read_smaps
 
def to_dict
 
def update
 
def update_proc
 
def update_ru
 

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.

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

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(), ApvTimingHistosUsingDb.update(), OptoScanHistosUsingDb.update(), PedestalsHistosUsingDb.update(), PedsFullNoiseHistosUsingDb.update(), NoiseHistosUsingDb.update(), PedsOnlyHistosUsingDb.update(), VpspScanHistosUsingDb.update(), PedestalsTask.update(), OptoScanTask.update(), CalibrationTask.update(), CalibrationScanTask.update(), FineDelayTask.update(), LatencyTask.update(), FastFedCablingHistosUsingDb.update(), cond::persistency::ITagTable.update(), SamplingHistosUsingDb.update(), FedCablingTask.update(), LatencyHistosUsingDb.update(), CalibrationHistosUsingDb.update(), NoiseTask.update(), PedsOnlyTask.update(), FineDelayHistosUsingDb.update(), PedsFullNoiseTask.update(), ora::PVectorUpdater.update(), cond::persistency::GLOBAL_TAG::Table.update(), BinomialProbability.update(), GraphPath< N, E >.update(), cond::persistency::TAG::Table.update(), HcaluLUTTPGCoder.update(), pos::PixelConfig.update(), ora::IRelationalUpdater.update(), SiStripConfObject.update(), ora::QueryableVectorUpdater.update(), ora::OraPtrUpdater.update(), LaserAlignmentSimulation.update(), ora::PrimitiveUpdater.update(), ora::UniqueRefUpdater.update(), ora::CArrayUpdater.update(), ora::OraReferenceUpdater.update(), ApvAnalysisFactory.update(), ora::ObjectUpdater.update(), ora::BlobUpdater.update(), ora::InlineCArrayUpdater.update(), DTVDriftCalibration::cellInfo.update(), ora::STLContainerUpdater.update(), ora::NamedRefUpdater.update(), cond::persistency::IPayloadMigrationTable.update(), ora::Container.update(), HLTScalersClient::CountLSFifo_t.update(), cond::persistency::IGTTable.update(), DTRecSegment2D.update(), ora::Database.update(), DQMNet::Peer.update, CommissioningTask.update(), DQMNet::AutoPeer.update, dqm-mbProfile.Profile.update(), and edmNew::DetSetVector< T >.update().

Referenced by progressbar.ProgressBar.__next__().

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

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

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

144  def read_smaps(self, proc_dict):
145  Private, Shared, Pss = 0, 0, 0
146 
147  fp = os.path.join("/proc/%d" % proc_dict["pid"], "smaps")
148  with open(fp) as fd:
149  for line in fd.readlines():
150  if line.startswith("Shared"):
151  Shared += int(line.split()[1])
152  elif line.startswith("Private"):
153  Private += int(line.split()[1])
154  elif line.startswith("Pss"):
155  Pss += int(line.split()[1])
156 
157  proc_dict["smaps_shared"] = Shared * 1024
158  proc_dict["smaps_private"] = Private * 1024
159  proc_dict["smaps_pss"] = Pss * 1024
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, RPCObStatus::S_Item.time, DTTMax::InfoLayer.time, RPCObTemp::T_Item.time, dqm-mbProfile.Profile.time, and conddblib.TimeType.time.

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

199  def to_dict(self):
200  dct = collections.OrderedDict()
201  dct['time'] = self.time
202  dct['pid'] = self.pid
203  dct['final'] = self.final
204 
205  dct['ru_diff'] = dict(self.ru_diff)
206  dct['ru'] = dict((k, v) for k, v in inspect.getmembers(self.ru) if k.startswith('ru_'))
207  dct['known_pids'] = dict(self.known_pids)
208  return dct
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, RPCObStatus::S_Item.time, DTTMax::InfoLayer.time, RPCObTemp::T_Item.time, dqm-mbProfile.Profile.time, conddblib.TimeType.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().

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

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

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

Member Data Documentation

dqm-mbProfile.Profile._args
private

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

Referenced by Vispa.Main.Application.Application._readCommandLineAttributes().

dqm-mbProfile.Profile._file
private

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

Referenced by dqm-mbProfile.Profile.finish(), Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigDataAccessor.open(), Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigDataAccessor.process(), and dqm-mbProfile.Profile.update().

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

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

Referenced by dqm-mbProfile.Profile.finish(), and dqm-mbProfile.Profile.to_dict().

dqm-mbProfile.Profile.known_pids

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

Referenced by dqm-mbProfile.Profile.to_dict(), and dqm-mbProfile.Profile.update_proc().

dqm-mbProfile.Profile.pid

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

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

dqm-mbProfile.Profile.ru

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

Referenced by dqm-mbProfile.Profile.to_dict(), and dqm-mbProfile.Profile.update_ru().

dqm-mbProfile.Profile.ru_diff

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

Referenced by dqm-mbProfile.Profile.finish(), dqm-mbProfile.Profile.to_dict(), and dqm-mbProfile.Profile.update_ru().

dqm-mbProfile.Profile.time

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

Referenced by dqm-mbProfile.Profile.to_dict(), and dqm-mbProfile.Profile.update().