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

◆ __init__()

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, dataset, job_number, job_id, job_name, isDA, isMC, applyBOWS, applyEXTRACOND, extraconditions, runboundary, lumilist, intlumi, maxevents, gt, allFromGT, alignmentDB, alignmentTAG, apeDB, apeTAG, bowDB, bowTAG, vertextype, tracktype, refittertype, ttrhtype, applyruncontrol, ptcut, CMSSW_dir, the_dir)

Member Function Documentation

◆ finish()

def dqm-mbProfile.Profile.finish (   self)

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

References CommonAnalyzer._file, condhdf5tohdf5.H5Tag._file, condhdf5tohdf5.H5GlobalTag._file, dqm-mbProfile.Profile._file, P2GTTriggerResultsConverter.final, dqm-mbProfile.Profile.final, dqm-mbProfile.Profile.ru_diff, frozendict.frozendict.update, FastFedCablingTask.update(), ApvTimingTask.update(), FedTimingTask.update(), VpspScanTask.update(), PedestalsTask.update(), OptoScanTask.update(), DaqScopeModeHistosUsingDb.update(), AlignableDet.update(), FineDelayTask.update(), LatencyTask.update(), ApvTimingHistosUsingDb.update(), ErrorCorrelation.update(), OptoScanHistosUsingDb.update(), PedestalsHistosUsingDb.update(), PedsFullNoiseHistosUsingDb.update(), NoiseHistosUsingDb.update(), VpspScanHistosUsingDb.update(), PedsOnlyHistosUsingDb.update(), FedCablingTask.update(), FastFedCablingHistosUsingDb.update(), AlignableDetUnit.update(), edm::SubProcessParentageHelper.update(), AlignableGEMChamber.update(), AlignableGEMSuperChamber.update(), LatencyHistosUsingDb.update(), CalibrationScanTask.update(), CalibrationTask.update(), CalibrationHistosUsingDb.update(), PedsOnlyTask.update(), FineDelayHistosUsingDb.update(), PedsFullNoiseTask.update(), AlignableTracker.update(), DaqScopeModeTask.update(), AlignableCSCChamber.update(), NoiseTask.update(), AlignableComposite.update(), edm::ProductProvenanceLookup.update(), HGCalMappingCellIndexer.update(), cond::persistency::ITagTable.update(), cond::persistency::GLOBAL_TAG::Table.update(), AlignableMuon.update(), SiStripConfObject.update(), cond::persistency::TAG::Table.update(), Alignable.update(), LaserAlignmentSimulation.update(), DictTypes.SortedAndFixedKeysDict.update, HcaluLUTTPGCoder.update(), ApvAnalysisFactory.update(), DTVDriftCalibration::cellInfo.update(), DictTypes.FixedKeysDict.update, HLTScalersClient::CountLSFifo_t.update(), DTRecSegment2D.update(), DQMNet::Peer.update, DQMNet::AutoPeer.update, CommissioningTask.update(), cond::persistency::IGTTable.update(), dqm-mbProfile.Profile.update(), Folder.update(), crabFunctions.CrabTask.update(), edmNew::DetSetVector< T >.update(), and Config.FilteredStream.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 

◆ read_smaps()

def dqm-mbProfile.Profile.read_smaps (   self,
  proc_dict 
)

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

References dqm-mbProfile.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 

◆ to_dict()

def dqm-mbProfile.Profile.to_dict (   self)

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

References P2GTTriggerResultsConverter.final, dqm-mbProfile.Profile.final, dqm-mbProfile.Profile.known_pids, dqm-mbProfile.Profile.pid, dqm-mbProfile.Profile.ru, dqm-mbProfile.Profile.ru_diff, reco::HcalMuonRecHit.time, RPCStripNoises::NoiseItem.time, RPCObImon::I_Item.time, RPCObGas::Item.time, ecal::RecHit< StoragePolicy >.time, RPCObFebmap::Feb_Item.time, RecoObj.time, RPCObVmon::V_Item.time, classes.PedeDumpData.time, RPCObStatus::S_Item.time, DTTMax::InfoLayer.time, RPCObTemp::T_Item.time, dqm-mbProfile.Profile.time, and l1t::EMTFHit.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 

◆ update()

def dqm-mbProfile.Profile.update (   self)

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

References mps_alisetup.SetupAlignment._args, tkal_create_file_lists.FileListCreator._args, dqm-mbProfile.Profile._args, conddb2hdf5.DBPayloadIterator._args, conddb2hdf5.DBDataProduct._args, conddb2hdf5.DBTag._args, conddb2hdf5.DBGlobalTag._args, CommonAnalyzer._file, condhdf5tohdf5.H5Tag._file, condhdf5tohdf5.H5GlobalTag._file, dqm-mbProfile.Profile._file, reco::HcalMuonRecHit.time, RPCStripNoises::NoiseItem.time, RPCObImon::I_Item.time, RPCObGas::Item.time, ecal::RecHit< StoragePolicy >.time, RPCObFebmap::Feb_Item.time, RecoObj.time, RPCObVmon::V_Item.time, classes.PedeDumpData.time, RPCObStatus::S_Item.time, DTTMax::InfoLayer.time, RPCObTemp::T_Item.time, dqm-mbProfile.Profile.time, l1t::EMTFHit.time, dqm-mbProfile.Profile.to_dict(), dqm-mbProfile.Profile.update_proc(), dqm-mbProfile.Profile.update_ru(), and writeEcalDQMStatus.write.

Referenced by progressbar.ProgressBar.__next__(), MatrixUtil.Matrix.__setitem__(), MatrixUtil.Steps.__setitem__(), dqm-mbProfile.Profile.finish(), progressbar.ProgressBar.finish(), and MatrixUtil.Steps.overwrite().

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 
#define update(a, b)

◆ update_proc()

def dqm-mbProfile.Profile.update_proc (   self)

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

References dqm-mbProfile.get_children(), relativeConstraints.keys, 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)

◆ update_ru()

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

◆ _args

dqm-mbProfile.Profile._args
private

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

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

◆ _file

dqm-mbProfile.Profile._file
private

◆ _offset_ru

dqm-mbProfile.Profile._offset_ru
private

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

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

◆ final

dqm-mbProfile.Profile.final

◆ known_pids

dqm-mbProfile.Profile.known_pids

◆ pid

dqm-mbProfile.Profile.pid

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

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

◆ ru

dqm-mbProfile.Profile.ru

◆ ru_diff

dqm-mbProfile.Profile.ru_diff

◆ time

dqm-mbProfile.Profile.time

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

Referenced by edmTracerCompactLogViewer.EDModuleTransitionParser._postJson(), edmTracerCompactLogViewer.ESModuleTransitionParser._postJson(), edmModuleAllocMonitorAnalyze.EDModuleTransitionParser._postJsonInfo(), edmModuleAllocMonitorAnalyze.ESModuleTransitionParser._postJsonInfo(), edmModuleAllocMonitorAnalyze.EDModuleTransitionParser._postJsonVis(), edmModuleAllocMonitorAnalyze.ESModuleTransitionParser._postJsonVis(), edmTracerCompactLogViewer.EDModuleTransitionParser._preJson(), edmTracerCompactLogViewer.ESModuleTransitionParser._preJson(), edmModuleAllocMonitorAnalyze.EDModuleTransitionParser._preJsonInfo(), edmModuleAllocMonitorAnalyze.ESModuleTransitionParser._preJsonInfo(), edmModuleAllocMonitorAnalyze.EDModuleTransitionParser._preJsonVis(), edmModuleAllocMonitorAnalyze.ESModuleTransitionParser._preJsonVis(), edmTracerCompactLogViewer.QueuingFrameworkTransitionParser.jsonInfo(), edmModuleAllocMonitorAnalyze.PostFrameworkTransitionParser.jsonInfo(), edmModuleAllocMonitorAnalyze.PreSourceTransitionParser.jsonInfo(), edmTracerCompactLogViewer.PostEDModulePrefetchingParser.jsonInfo(), edmTracerCompactLogViewer.PostEDModuleAcquireParser.jsonInfo(), edmModuleAllocMonitorAnalyze.PostSourceTransitionParser.jsonInfo(), edmModuleAllocMonitorAnalyze.PreEventReadFromSourceParser.jsonInfo(), edmModuleAllocMonitorAnalyze.PostEventReadFromSourceParser.jsonInfo(), edmModuleAllocMonitorAnalyze.PreFrameworkTransitionParser.jsonVisInfo(), edmModuleAllocMonitorAnalyze.PostFrameworkTransitionParser.jsonVisInfo(), edmModuleAllocMonitorAnalyze.PostEDModuleAcquireParser.jsonVisInfo(), edmTracerCompactLogViewer.FrameworkTransitionParser.textPrefix(), edmTracerCompactLogViewer.SourceTransitionParser.textPrefix(), edmModuleAllocMonitorAnalyze.FrameworkTransitionParser.textPrefix(), edmTracerCompactLogViewer.EDModuleTransitionParser.textPrefix(), edmModuleAllocMonitorAnalyze.SourceTransitionParser.textPrefix(), edmTracerCompactLogViewer.ESModuleTransitionParser.textPrefix(), edmModuleAllocMonitorAnalyze.EDModuleTransitionParser.textPrefix(), edmModuleAllocMonitorAnalyze.ESModuleTransitionParser.textPrefix(), dqm-mbProfile.Profile.to_dict(), and dqm-mbProfile.Profile.update().