ATLAS Offline Software
PerfMonSvc.h
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // PerfMonSvc.h
8 // Header file for class PerfMonSvc
9 // Author: S.Binet<binet@cern.ch>
11 #ifndef PERFMONCOMPS_PERFMONSVC_H
12 #define PERFMONCOMPS_PERFMONSVC_H 1
13 
14 // Local includes
15 #include "LinFitSglPass.h"
16 
17 // C includes
18 #include <stdio.h>
19 
20 // STL includes
21 #include <string>
22 #include <iosfwd>
23 #include <unordered_map>
24 
25 // FrameWork includes
26 #include "GaudiKernel/INamedInterface.h"
27 #include "GaudiKernel/ServiceHandle.h"
28 #include "GaudiKernel/IIncidentListener.h"
29 #include "GaudiKernel/StatEntity.h"
30 #include "GaudiKernel/IIoComponent.h"
33 
34 // PerfMonKernel includes
36 
37 // PerfMonEvent includes
38 #include "PerfMonEvent/DataModel.h"
39 
40 // Forward declaration
41 class ISvcLocator;
42 template <class TYPE> class SvcFactory;
43 class IChronoStatSvc;
44 class StoreGateSvc;
45 struct _object; typedef _object PyObject;
46 
47 namespace PerfMon {
48  struct Tuple
49  {
50  typedef std::unordered_map<std::string, PerfMon::Component> CompStore_t;
51  typedef std::unordered_map<std::string,PerfMon::IoContainer> IoCompStore_t;
52 
53  typedef std::unordered_map<std::string, CompStore_t> CompTuple_t;
54  typedef std::unordered_map<std::string,IoCompStore_t> IoCompTuple_t;
55 
58  };
59 } //> namespace PerfMon
60 
61 namespace PMonSD { class SemiDetHelper; }
62 
64  virtual public IIncidentListener,
65  virtual public IIoComponent,
66  public AthService
67 {
68 
69 protected:
70 
71  friend class SvcFactory<PerfMonSvc>;
72 
74  // Public methods:
76 public:
77 
78  // Copy constructor:
79 
81  PerfMonSvc( const std::string& name, ISvcLocator* pSvcLocator );
82 
84  virtual ~PerfMonSvc();
85 
87 
88  virtual StatusCode initialize() override;
89  virtual StatusCode finalize() override;
90  virtual StatusCode queryInterface( const InterfaceID& riid,
91  void** ppvInterface ) override;
93 
95 
96 
99  virtual
100  StatusCode io_reinit() override final;
101  virtual
102  StatusCode io_finalize() override final;
104 
106  // Const methods:
108 
110  virtual
111  std::vector<std::string>
112  components(const std::string& stepName) const override;
113 
115  virtual
116  std::vector<std::string>
117  io_components() const override;
118 
121  virtual
122  const PerfMon::Component*
123  component(const std::string& stepName,
124  const std::string& compName) const override;
125 
127  virtual
128  const PerfMon::IoContainer*
129  io_component(const std::string& compName) const override;
130 
132  virtual
133  void
134  domain(const std::string& compName, std::string& domain) const override;
135 
137  // Non-const methods:
139 
140  static const InterfaceID& interfaceID();
141 
144  virtual
145  void handle( const Incident& incident ) override;
146 
153  virtual void declareInfo( const std::string& name,
154  const bool& var,
155  const std::string& desc,
156  const IInterface* owner ) override;
157  virtual void declareInfo( const std::string& name,
158  const int& var,
159  const std::string& desc,
160  const IInterface* owner ) override;
161  virtual void declareInfo( const std::string& name,
162  const long& var,
163  const std::string& desc,
164  const IInterface* owner ) override;
165  virtual void declareInfo( const std::string& name,
166  const double& var,
167  const std::string& desc,
168  const IInterface* owner ) override;
169  virtual void declareInfo( const std::string& name,
170  const std::string& var,
171  const std::string& desc,
172  const IInterface* owner ) override;
173  virtual void declareInfo( const std::string& name,
174  const std::pair<double,double>& var,
175  const std::string& desc,
176  const IInterface* owner ) override;
177  virtual void declareInfo( const std::string& name,
178  const AIDA::IBaseHistogram* var,
179  const std::string& desc,
180  const IInterface* owner ) override;
181  virtual void declareInfo( const std::string& name,
182  const std::string& format,
183  const void * var, int size,
184  const std::string& desc,
185  const IInterface* owner ) override;
186  virtual void declareInfo(const std::string& name,
187  const StatEntity& var,
188  const std::string& desc,
189  const IInterface* owner) override;
190 
195  virtual void undeclareInfo( const std::string& name,
196  const IInterface* owner ) override;
200  virtual void undeclareAll( const IInterface* owner ) override;
201 
206  virtual std::set<std::string>* getInfos( const IInterface* owner ) override;
207 
208 
212  void startAud( const std::string& stepName, const std::string& compName ) override;
213 
217  void stopAud ( const std::string& stepName, const std::string& compName ) override;
218 
220  // Private methods:
222 private:
223 
226 
228  void setupProfiledAlgList( Gaudi::Details::PropertyBase& profiledAlgNames );
229 
231  void setupIoContainerList( Gaudi::Details::PropertyBase& ioContainerNames );
232 
235  void poll();
236 
239  void comp_startAud(const std::string& stepName,
240  const std::string& compName);
241 
244  void comp_stopAud(const std::string& stepName,
245  const std::string& compName);
246 
249  void do_io_mon();
250 
251  void postFinalize();
252 
254  // Private data:
256 private:
257 
260 
263 
266  DoubleProperty m_deltaVMemAlert;
267 
270  StringArrayProperty m_profiledAlgNames;
271 
275  StringArrayProperty m_ioContainerNames;
276 
278  StringProperty m_outFileName;
279 
282 
284  int m_monLvl;
285 
287  StringProperty m_shelveFileName;
288 
291 
293  std::string m_jobStartJiffies;
294 
295  //Trigger tons of extra printouts, before and after each component
297 
300 
302  float m_firstVmem;
303 
305  float m_10evtVmem;
306 
308  float m_lastVmem;
309 
313 
315  int m_stream;
316 
318  std::string m_workerDir;
319 
321  long m_nevts;
322 
324  std::size_t m_nalgs;
325 
326  struct Stats_t {
327  StatEntity cpu;
328  StatEntity cpu_user;
329  StatEntity cpu_sys;
330  StatEntity real;
331  StatEntity vmem;
332  StatEntity malloc;
333  StatEntity nalloc;
334  StatEntity rt;
335  };
336  typedef std::unordered_map<std::string, Stats_t> StatStore_t;
338 
339  // a struct which shadows PerfMon::Mem to correct for double counting
340  // memory-related resources in possible deeply nested callgraphs
341  struct CgHandler {
342  float vmem;
343  float rss;
344  float mall;
345  float nmall;
346  float nfree;
347 
349  vmem(0.), rss(0.), mall(0.), nmall(0.), nfree(0.)
350  {}
351  };
353 
354  //PMonSD:
356 
357  bool m_pf;
358 
359 private:
360 
361  // In serial Athena each job starts w/ Before AthMasterSeq Execute auditor call
362  // and ends w/ After AthMasterSeq Execute auditor call. However, in MT this is
363  // not the case. Although this Service is not MT-safe (see PerfMonMTSvc)
364  // we still use it in MT = 1 jobs. There we use the incident algorithms as a
365  // workaround.
366 
367  // Component name that'll trigger begin event
368  Gaudi::Property<std::string> m_compBeginEvent {
369  this, "compBeginEvent", "AthMasterSeq", "Component name that'll trigger begin event" };
370 
371  // Component name that'll trigger end event
372  Gaudi::Property<std::string> m_compEndEvent {
373  this, "compEndEvent", "AthMasterSeq", "Component name that'll trigger end event" };
374 };
375 
379 
380 inline const InterfaceID& PerfMonSvc::interfaceID()
381 {
382  return IPerfMonSvc::interfaceID();
383 }
384 
385 #endif //> PERFMONCOMPS_PERFMONSVC_H
PerfMonSvc::m_shelveFileName
StringProperty m_shelveFileName
Name of the shelve file containing jobo metadata.
Definition: PerfMonSvc.h:287
PerfMonSvc::m_deltaVMemAlert
DoubleProperty m_deltaVMemAlert
Maximum allowed variation of virtual memory (in bytes) between last print-out and current vmem value,...
Definition: PerfMonSvc.h:266
IPerfMonSvc::declareInfo
virtual void declareInfo(const std::string &name, const bool &var, const std::string &desc, const IInterface *owner)=0
Declare monitoring information.
PerfMonSvc::m_jobStartJiffies
std::string m_jobStartJiffies
(needed as a property to survive athena.py –drop-and-reload
Definition: PerfMonSvc.h:293
PerfMonSvc::Stats_t::cpu
StatEntity cpu
Definition: PerfMonSvc.h:327
LinFitSglPass.h
beamspotnt.var
var
Definition: bin/beamspotnt.py:1394
PMonSD::SemiDetHelper
Definition: SemiDetHelper.h:50
python.tests.PyTestsLib.finalize
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
Definition: PyTestsLib.py:53
AddEmptyComponent.compName
compName
Definition: AddEmptyComponent.py:32
PerfMon::Tuple::IoCompTuple_t
std::unordered_map< std::string, IoCompStore_t > IoCompTuple_t
Definition: PerfMonSvc.h:54
PerfMonSvc::StatStore_t
std::unordered_map< std::string, Stats_t > StatStore_t
Definition: PerfMonSvc.h:336
PerfMonSvc::CgHandler::vmem
float vmem
Definition: PerfMonSvc.h:342
PerfMon::LinFitSglPass
Definition: LinFitSglPass.h:22
PerfMonSvc::CgHandler::mall
float mall
Definition: PerfMonSvc.h:344
PerfMonSvc::Stats_t::real
StatEntity real
Definition: PerfMonSvc.h:330
PerfMonSvc::m_enableDblCountingCorrection
BooleanProperty m_enableDblCountingCorrection
switch to enable or not the on-the-fly double-counting correction
Definition: PerfMonSvc.h:281
IPerfMonSvc::component
const PerfMon::Component * component(PerfMon::State::Type step, const std::string &compName) const
retrieve the monitored value for the component compName and for the step step (ini,...
Definition: IPerfMonSvc.h:78
PerfMonSvc::m_stats
StatStore_t m_stats
Definition: PerfMonSvc.h:337
IPerfMonSvc::io_component
virtual const PerfMon::IoContainer * io_component(const std::string &compName) const =0
retrieve the I/O monitored value for the I/O component compName
vtune_athena.format
format
Definition: vtune_athena.py:14
PerfMonSvc::m_pf
bool m_pf
Definition: PerfMonSvc.h:357
ATLAS_NOT_THREAD_SAFE
#define ATLAS_NOT_THREAD_SAFE
getNoisyStrip() Find noisy strips from hitmaps and write out into xml/db formats
Definition: checker_macros.h:212
PerfMonSvc::m_pmonsd
PMonSD::SemiDetHelper * m_pmonsd
Definition: PerfMonSvc.h:355
initialize
void initialize()
Definition: run_EoverP.cxx:894
IoCompTuple_t
PerfMon::Tuple::IoCompTuple_t IoCompTuple_t
Definition: PerfMonSvc.cxx:95
SvcFactory
Definition: AthCnvSvc.h:28
PerfMonSvc::CgHandler::rss
float rss
Definition: PerfMonSvc.h:343
PerfMon::Tuple::IoCompStore_t
std::unordered_map< std::string, PerfMon::IoContainer > IoCompStore_t
Definition: PerfMonSvc.h:51
IPerfMonSvc::undeclareInfo
virtual void undeclareInfo(const std::string &name, const IInterface *owner)=0
Undeclare monitoring information.
PerfMonSvc::m_extraPrintouts
bool m_extraPrintouts
Definition: PerfMonSvc.h:296
PerfMonSvc::m_semiDetMonLvl
int m_semiDetMonLvl
Level of semi-detailed monitoring.
Definition: PerfMonSvc.h:290
PerfMonSvc::CgHandler::nmall
float nmall
Definition: PerfMonSvc.h:345
IPerfMonSvc::startAud
virtual void startAud(const std::string &stepName, const std::string &compName="PerfMonSlice")=0
Start collecting monitoring data for a given component, for a given step of the Gaudi FSM.
PerfMonSvc::m_nevts
long m_nevts
number of events processed during the monitored job
Definition: PerfMonSvc.h:321
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
PerfMonSvc::m_chrono
ServiceHandle< IChronoStatSvc > m_chrono
handle to the chronostat service
Definition: PerfMonSvc.h:262
IPerfMonSvc::domain
virtual void domain(const std::string &compName, std::string &domain) const =0
retrieve the domain name for a given component compName
PerfMonSvc::interfaceID
static const InterfaceID & interfaceID()
Inline methods:
Definition: PerfMonSvc.h:380
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:128
PerfMonSvc
Definition: PerfMonSvc.h:67
PerfMon
a simple malloc wrapper that keeps track of the amount of memory allocated on the heap.
Definition: CallGraphAuditor.cxx:24
CaloCondBlobAlgs_fillNoiseFromASCII.desc
desc
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:54
PerfMon::Tuple::CompTuple_t
std::unordered_map< std::string, CompStore_t > CompTuple_t
Definition: PerfMonSvc.h:53
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
PerfMonSvc::Stats_t::rt
StatEntity rt
Definition: PerfMonSvc.h:334
AthService
Definition: AthService.h:32
PerfMonSvc::m_pySvc
PyObject * m_pySvc
Pointer to the PyObject doing the real work.
Definition: PerfMonSvc.h:259
PerfMonSvc::m_firstVmem
float m_firstVmem
first event vmem
Definition: PerfMonSvc.h:302
PerfMonSvc::m_outFileName
StringProperty m_outFileName
Name of the output file to hold performance data.
Definition: PerfMonSvc.h:278
PerfMon::Component
Definition: DataModel.h:73
PerfMon::Tuple
Definition: PerfMonSvc.h:49
PerfMonSvc::m_vmemfit_evt101plus
PerfMon::LinFitSglPass m_vmemfit_evt101plus
Definition: PerfMonSvc.h:312
PMonSD
Definition: PerfMonSvc.h:61
PerfMonSvc::m_ioContainerNames
StringArrayProperty m_ioContainerNames
List of containers for which one wants to gather I/O data.
Definition: PerfMonSvc.h:275
PerfMon::Tuple::CompStore_t
std::unordered_map< std::string, PerfMon::Component > CompStore_t
Definition: PerfMonSvc.h:50
PerfMonSvc::m_profiledAlgNames
StringArrayProperty m_profiledAlgNames
List of algorithms to be profiled.
Definition: PerfMonSvc.h:270
PerfMonSvc::Stats_t::cpu_sys
StatEntity cpu_sys
Definition: PerfMonSvc.h:329
IPerfMonSvc.h
PerfMonSvc::m_vmemfit_evt21to100
PerfMon::LinFitSglPass m_vmemfit_evt21to100
Definition: PerfMonSvc.h:311
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
PerfMonSvc::m_stream
int m_stream
pmon-stream data file descriptor
Definition: PerfMonSvc.h:315
PerfMonSvc::PerfMonSvc
PerfMonSvc()
Default constructor:
IPerfMonSvc::io_components
virtual std::vector< std::string > io_components() const =0
return the list of io-components' names
PerfMonSvc::Stats_t::malloc
StatEntity malloc
Definition: PerfMonSvc.h:332
PerfMon::Tuple::iocomp
IoCompTuple_t iocomp
Definition: PerfMonSvc.h:57
PerfMonSvc::Stats_t
Definition: PerfMonSvc.h:326
PerfMonSvc::Stats_t::nalloc
StatEntity nalloc
Definition: PerfMonSvc.h:333
IPerfMonSvc
Definition: IPerfMonSvc.h:38
PerfMonSvc::m_10evtVmem
float m_10evtVmem
10th-event vmem
Definition: PerfMonSvc.h:305
PerfMonSvc::CgHandler
Definition: PerfMonSvc.h:341
PerfMonSvc::m_lastVmem
float m_lastVmem
last event vmem
Definition: PerfMonSvc.h:308
IPerfMonSvc::undeclareAll
virtual void undeclareAll(const IInterface *owner)=0
Undeclare monitoring information.
PerfMonSvc::Stats_t::vmem
StatEntity vmem
Definition: PerfMonSvc.h:331
PerfMon::IoContainer
Definition: DataModel.h:67
PerfMonSvc::CgHandler::nfree
float nfree
Definition: PerfMonSvc.h:346
PerfMonSvc::m_workerDir
std::string m_workerDir
Worker directory in athenaMP.
Definition: PerfMonSvc.h:318
PerfMonSvc::m_vmemfit_evt2to20
PerfMon::LinFitSglPass m_vmemfit_evt2to20
Definition: PerfMonSvc.h:310
DataModel.h
AthService.h
PerfMonSvc::CgHandler::CgHandler
CgHandler()
Definition: PerfMonSvc.h:348
IPerfMonSvc::stopAud
virtual void stopAud(const std::string &stepName, const std::string &compName="PerfMonSlice")=0
Stop collecting monitoring data for a given component, for a given step of the Gaudi FSM.
PerfMonSvc::m_corrector
CgHandler m_corrector
Definition: PerfMonSvc.h:352
IPerfMonSvc::getInfos
virtual std::set< std::string > * getInfos(const IInterface *owner=0)=0
Get the names for all declared monitoring informations for a given owener.
checker_macros.h
Define macros for attributes used to control the static checker.
PyObject
_object PyObject
Definition: IPyComponent.h:26
PyObject
_object PyObject
Definition: PerfMonSvc.h:45
PerfMonSvc::m_monLvl
int m_monLvl
level of granularity for monitoring
Definition: PerfMonSvc.h:284
PerfMonSvc::m_nalgs
std::size_t m_nalgs
number of algorithms the monitored job ran
Definition: PerfMonSvc.h:324
IPerfMonSvc::components
std::vector< std::string > components(PerfMon::State::Type step) const
return the list of components' names for a given step
Definition: IPerfMonSvc.h:62
PerfMon::Tuple::comp
CompTuple_t comp
Definition: PerfMonSvc.h:56
IPerfMonSvc::interfaceID
static const InterfaceID & interfaceID()
Definition: IPerfMonSvc.h:200
PerfMonSvc::m_ntuple
PerfMon::Tuple m_ntuple
tuple of data (step->component[name->perf-data])
Definition: PerfMonSvc.h:299
PerfMonSvc::Stats_t::cpu_user
StatEntity cpu_user
Definition: PerfMonSvc.h:328
ServiceHandle< IChronoStatSvc >