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 

Member Function Documentation

◆ finish()

def dqm-mbProfile.Profile.finish (   self)

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

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 

References CommonAnalyzer._file, dqm-mbProfile.Profile._file, 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(), NoiseHistosUsingDb.update(), OptoScanHistosUsingDb.update(), PedestalsHistosUsingDb.update(), PedsFullNoiseHistosUsingDb.update(), ErrorCorrelation.update(), VpspScanHistosUsingDb.update(), PedsOnlyHistosUsingDb.update(), FedCablingTask.update(), FastFedCablingHistosUsingDb.update(), AlignableDetUnit.update(), edm::SubProcessParentageHelper.update(), AlignableGEMSuperChamber.update(), AlignableGEMChamber.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(), BinomialProbability.update(), edm::ProductProvenanceLookup.update(), cond::persistency::GLOBAL_TAG::Table.update(), cond::persistency::ITagTable.update(), AlignableMuon.update(), SiStripConfObject.update(), pos::PixelConfig.update(), cond::persistency::TAG::Table.update(), Alignable.update(), HcaluLUTTPGCoder.update(), LaserAlignmentSimulation.update(), DictTypes.SortedAndFixedKeysDict.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__().

◆ read_smaps()

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

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

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 

References dqm-mbProfile.int.

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

◆ to_dict()

def dqm-mbProfile.Profile.to_dict (   self)

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

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 

References 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, popcon::PopConSourceHandler< T >::Triplet.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().

◆ update()

def dqm-mbProfile.Profile.update (   self)

◆ update_proc()

def dqm-mbProfile.Profile.update_proc (   self)

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

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 

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

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

◆ update_ru()

def dqm-mbProfile.Profile.update_ru (   self)

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

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 

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

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

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
dqm-mbProfile.get_children
def get_children(ppid)
Definition: dqm-mbProfile.py:65
dqm-mbProfile.int
int
Definition: dqm-mbProfile.py:292
relativeConstraints.keys
keys
Definition: relativeConstraints.py:89
writeEcalDQMStatus.write
write
Definition: writeEcalDQMStatus.py:48
update
#define update(a, b)
Definition: TrackClassifier.cc:10