| The Gaudi Framework v32r1 (f65d50dc)

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/IChronoStatSvc.h"
8 #include "GaudiKernel/MsgStream.h"
9
10 #include "GaudiKernel/Stat.h"
11
13 #include "MemStatAuditor.h"
14 #include "ProcStats.h"
15
16 DECLARE_COMPONENT( MemStatAuditor )
17
18 StatusCode MemStatAuditor::initialize() {
19 StatusCode sc = CommonAuditor::initialize();
20 if ( UNLIKELY( sc.isFailure() ) ) return sc;
21
22 m_stat = serviceLocator()->service( "ChronoStatSvc" );
23 if ( UNLIKELY( !m_stat.get() ) ) {
24 error() << "Cannot get ChronoStatSvc" << endmsg;
25 return StatusCode::FAILURE;
26 }
27 return StatusCode::SUCCESS;
28 }
29
30 void MemStatAuditor::i_before( CustomEventTypeRef /*evt*/, const std::string& /*caller*/ ) {
31 // It's not interesting to monitor the memory usage before the methods.
32 }
33
34 void MemStatAuditor::i_printinfo( const std::string& msg, CustomEventTypeRef evt, const std::string& caller ) {
35 // cannot be exactly 0
36 double deltaVSize = 0.00001;
37
38 procInfo pInfo;
39 if ( getProcInfo( pInfo ) ) {
40
41 if ( pInfo.vsize > 0 ) {
42 if ( m_vSize > 0 ) { deltaVSize = pInfo.vsize - m_vSize; }
43 // store the current VSize to be able to monitor the increment
44 m_vSize = pInfo.vsize;
45 }
46
47 info() << msg << " " << caller << " " << evt << " \tvirtual size = " << pInfo.vsize << " MB"
48 << " \tresident set size = " << pInfo.rss << " MB"
49 << " deltaVsize = " << deltaVSize << " MB" << endmsg;
50 }
51 // fill the stat for every call, not just when there is a change
52 // only monitor the increment in VSize
53 // Stat stv(statSvc(), caller + ":VMemUsage", pInfo.vsize);
54 // Stat str(statSvc(), caller + ":RMemUsage", pInfo.rss);
55 Stat sts( statSvc(), caller + ":VMem", deltaVSize );
56 }
UNLIKELY
#define UNLIKELY(x)
Definition: Kernel.h:96
MemStatAuditor
Just a minor modification of MemoryAuditor to allow the output memory statistics table to be printed.
Definition: MemStatAuditor.h:15
MsgStream.h
Stat
Small wrapper class for easy manipulation with generic counters and IStatSvc interface.
Definition: Stat.h:46
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:104
std::string
STL class.
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition: PluginServiceV1.h:46
procInfo::rss
double rss
Definition: ProcStats.h:38
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
MemStatAuditor::m_vSize
double m_vSize
vsize of the previous call to printinfo
Definition: MemStatAuditor.h:31
MemoryAuditor::getProcInfo
static bool getProcInfo(procInfo &info)
Get the process informations.
Definition: MemoryAuditor.h:27
CommonMessagingBase::msg
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:113
ProcStats.h
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
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:30
Stat.h
IChronoStatSvc.h
Auditor::initialize
virtual StatusCode initialize()
Definition: Auditor.cpp:64
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:130
procInfo::vsize
double vsize
Definition: ProcStats.h:37
MemStatAuditor::statSvc
SmartIF< IChronoStatSvc > & statSvc()
Definition: MemStatAuditor.h:27
procInfo
Definition: ProcStats.h:17
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
IOTest.evt
evt
Definition: IOTest.py:94
MemStatAuditor::i_printinfo
void i_printinfo(const std::string &msg, CustomEventTypeRef evt, const std::string &caller) override
Report the memory usage.
Definition: MemStatAuditor.cpp:34
MemStatAuditor.h