| The Gaudi Framework v27r1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

MemStatAuditor.cpp
Go to the documentation of this file.
1 #ifdef __ICC
2 // disable icc warning #654: overloaded virtual function "B::Y" is only partially overridden in class "C"
3 // TODO: there is only a partial overload of IAuditor::before and IAuditor::after
4 #pragma warning(disable:654)
5 #endif
6
7 #include "GaudiKernel/MsgStream.h"
8 #include "GaudiKernel/IChronoStatSvc.h"
9
10 #include "GaudiKernel/Stat.h"
11
13 #include "ProcStats.h"
14 #include "MemStatAuditor.h"
15
16 DECLARE_COMPONENT(MemStatAuditor)
17
18 MemStatAuditor::MemStatAuditor(const std::string& name, ISvcLocator* pSvcLocator) :
19 MemoryAuditor(name, pSvcLocator)
20 {
21 }
22
23 StatusCode MemStatAuditor::initialize() {
24 StatusCode sc = CommonAuditor::initialize();
25 if (UNLIKELY(sc.isFailure())) return sc;
26
27 m_stat = serviceLocator()->service("ChronoStatSvc");
28 if (UNLIKELY(!m_stat.get())) {
29 error() << "Cannot get ChronoStatSvc" << endmsg;
30 return StatusCode::FAILURE;
31 }
32 return StatusCode::SUCCESS;
33 }
34
35 void MemStatAuditor::i_before(CustomEventTypeRef /*evt*/, const std::string& /*caller*/) {
36 // It's not interesting to monitor the memory usage before the methods.
37 }
38
39 void MemStatAuditor::i_printinfo(const std::string& msg, CustomEventTypeRef evt, const std::string& caller) {
40 // cannot be exactly 0
41 double deltaVSize = 0.00001;
42
43 procInfo pInfo;
44 if (getProcInfo(pInfo)) {
45
46 if (pInfo.vsize > 0) {
47 if (m_vSize > 0){
48 deltaVSize = pInfo.vsize - m_vSize;
49 }
50 // store the current VSize to be able to monitor the increment
51 m_vSize = pInfo.vsize;
52 }
53
54 info() << msg << " " << caller << " " << evt <<
55 " \tvirtual size = " << pInfo.vsize << " MB" <<
56 " \tresident set size = " << pInfo.rss << " MB" <<
57 " deltaVsize = " << deltaVSize << " MB" << endmsg;
58 }
59 // fill the stat for every call, not just when there is a change
60 // only monitor the increment in VSize
61 // Stat stv(statSvc(), caller + ":VMemUsage", pInfo.vsize);
62 // Stat str(statSvc(), caller + ":RMemUsage", pInfo.rss);
63 Stat sts(statSvc(), caller + ":VMem", deltaVSize);
64 }
UNLIKELY
#define UNLIKELY(x)
Definition: Kernel.h:126
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
MemStatAuditor
Just a minor modification of MemoryAuditor to allow the output memory statistics table to be printed...
Definition: MemStatAuditor.h:15
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:28
GaudiMP.FdsRegistry.msg
tuple msg
Definition: FdsRegistry.py:8
MsgStream.h
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:124
Stat
Small wrapper class for easy manipulation with generic counters and IStatSvc&ICounterSvc interface...
Definition: Stat.h:46
std
STL namespace.
MemStatAuditor::initialize
StatusCode initialize() override
Definition: MemStatAuditor.cpp:23
merge_files.sc
int sc
Definition: merge_files.py:167
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition: PluginService.h:36
std::string
STL class.
SmartIF::get
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:76
ISvcLocator::service
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:78
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:118
StatusCode::FAILURE
Definition: StatusCode.h:29
procInfo::rss
double rss
Definition: ProcStats.h:38
StatusCode::SUCCESS
Definition: StatusCode.h:30
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
read_lhcb_event_file.evt
tuple evt
Definition: read_lhcb_event_file.py:14
MemStatAuditor::m_vSize
double m_vSize
vsize of the previous call to printinfo
Definition: MemStatAuditor.h:31
Auditor::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const
The standard service locator.
Definition: Auditor.cpp:211
MemStatAuditor::m_stat
SmartIF< IChronoStatSvc > m_stat
Definition: MemStatAuditor.h:28
MemoryAuditor::getProcInfo
static bool getProcInfo(procInfo &info)
Get the process informations.
Definition: MemoryAuditor.h:27
ProcStats.h
MemStatAuditor::i_before
void i_before(CustomEventTypeRef evt, const std::string &caller) override
Re-implement i_before to avoid monitoring the memory usage before a function.
Definition: MemStatAuditor.cpp:35
Stat.h
IChronoStatSvc.h
Auditor::initialize
virtual StatusCode initialize()
Definition: Auditor.cpp:82
MemoryAuditor
Monitors the memory use of each algorithm.
Definition: MemoryAuditor.h:11
procInfo::vsize
double vsize
Definition: ProcStats.h:37
MemStatAuditor::statSvc
SmartIF< IChronoStatSvc > & statSvc()
Definition: MemStatAuditor.h:27
procInfo
Definition: ProcStats.h:16
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
MemStatAuditor::i_printinfo
void i_printinfo(const std::string &msg, CustomEventTypeRef evt, const std::string &caller) override
Report the memory usage.
Definition: MemStatAuditor.cpp:39
MemStatAuditor.h