18 #include "boost/assign/list_of.hpp" 20 #ifdef TCMALLOC_OLD_GOOGLE_HEADERS 21 #include "google/heap-checker.h" 22 #include "google/heap-profiler.h" 23 #include "google/profiler.h" 25 #include "gperftools/heap-checker.h" 26 #include "gperftools/heap-profiler.h" 27 #include "gperftools/profiler.h" 45 using extends::extends;
55 inSvc->addListener(
this, IncidentType::BeginEvent );
99 return ( dynamic_cast<GaudiSequencer*>( i ) != NULL || dynamic_cast<Sequencer*>( i ) != NULL );
119 t << name <<
"-" <<
type;
120 if ( type ==
"Execute" ) t <<
"-Event" <<
m_nEvts;
132 if ( IncidentType::BeginEvent == incident.
type() ) {
177 info() <<
"Starting Auditor for " << s <<
":" << type <<
endmsg;
181 warning() <<
"Auditor already running. Cannot be started for " << s <<
endmsg;
253 {
"Initialize",
"ReInitialize",
"Execute",
"BeginRun",
"EndRun",
"Finalize"},
254 "List of phases to activate the Auditoring during"};
256 this,
"DisableFor", {},
"List of component names to disable the auditing for"};
258 this,
"EnableFor", {},
"Any component in this list will be audited. If empty, all will be done."};
261 this,
"DoFullEventProfile",
false,
262 "If true, instead of individually auditing components, the full event (or events) will be audited in one go"};
264 this,
"FullEventNSampleEvents", 1,
"The number of events to include in a full event audit, if enabled"};
266 "Number of events to skip before activating the auditing"};
268 "If true, auditing will be skipped for Sequencer objects."};
296 using AuditorBase::AuditorBase;
303 if ( m_dumpProfileHeaps ) {
304 HeapProfilerDump( s.
c_str() );
306 if ( m_printProfilesToLog ) {
307 const char* profile = GetHeapProfile();
339 using AuditorBase::AuditorBase;
346 const char* HEAPCHECK = getenv(
"HEAPCHECK" );
348 fatal() <<
"Environment variable HEAPCHECK must be set to 'local'" <<
endmsg;
352 warning() <<
"Environment variable HEAPCHECK is set to " << HEAPCHECK
353 <<
" Partial Program Heap Checking is disabled" <<
endmsg;
363 if ( m_enabled && !m_checker ) {
364 m_checker.reset(
new HeapLeakChecker( s.
c_str() ) );
370 if ( m_enabled && m_checker ) {
371 if ( !m_checker->NoLeaks() ) {
381 bool m_enabled =
true;
402 using AuditorBase::AuditorBase;
409 ProfilerStart( ( s +
".prof" ).c_str() );
424 bool m_running =
false;
void afterReinitialize(INamedInterface *i) override
Gaudi::Property< std::vector< std::string > > m_list
constexpr static const auto FAILURE
std::string m_startedBy
Name of the component we are currently auditing.
void beforeBeginRun(INamedInterface *i) override
void google_after(const std::string &) override
stop the google tool
void stopAudit()
stop a full event audit
Gaudi::Property< std::vector< std::string > > m_when
const std::string & type() const
Access to the incident type.
void beforeFinalize(INamedInterface *i) override
std::unique_ptr< HeapLeakChecker > m_checker
Implementation of property with value of concrete type.
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
virtual void google_before(const std::string &s)=0
Start the google tool.
void google_after(const std::string &s) override
stop the google tool
bool m_audit
Internal flag to say if auditing is enabled or not for the current event.
void before(StandardEventType type, INamedInterface *i) override
void startAudit()
Start a full event audit.
void google_before(const std::string &s) override
Start the google tool.
Gaudi::Property< int > m_freq
void handle(const Incident &incident) override
Implement the handle method for the Incident service.
Gaudi::Property< bool > m_fullEventAudit
virtual bool alreadyRunning()=0
check if we are already running the tool
StatusCode initialize() override
Initialize the auditor base.
void afterBeginRun(INamedInterface *i) override
StatusCode finalize() override
Finalize the auditor base.
bool m_inFullAudit
Internal flag to indicate if we are current in a full event audit.
void google_after(const std::string &s) override
stop the google tool
unsigned long long m_sampleEventCount
Internal count of the number of events currently processed during an audit.
#define DECLARE_COMPONENT(type)
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
void before(CustomEventTypeRef type, INamedInterface *i) override
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
unsigned long long m_nEvts
Number of events processed.
bool isPhaseEnabled(CustomEventTypeRef type) const
Check if auditing is enabled for the current processing phase.
void after(CustomEventTypeRef type, const std::string &s, const StatusCode &) override
bool alreadyRunning() override
check if we are already running the tool
This class is used for returning status codes from appropriate routines.
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
void afterExecute(INamedInterface *i, const StatusCode &s) override
Auditor using the Google Heap Checker.
std::string getDumpName(CustomEventTypeRef type, const std::string &name) const
void before(CustomEventTypeRef type, const std::string &s) override
void beforeInitialize(INamedInterface *i) override
Gaudi::Property< unsigned long long > m_nSampleEvents
constexpr static const auto SUCCESS
bool alreadyRunning() override
check if we are already running the tool
IInterface compliant class extending IInterface with the name() method.
void beforeEndRun(INamedInterface *i) override
void afterInitialize(INamedInterface *i) override
void beforeReinitialize(INamedInterface *i) override
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Base class used to extend a class implementing other interfaces.
Gaudi::Property< unsigned long long > m_eventsToSkip
void before(StandardEventType type, const std::string &s) override
void google_before(const std::string &s) override
Start the google tool.
Base class for all Incidents (computing events).
Gaudi::Property< bool > m_skipSequencers
void after(StandardEventType type, const std::string &s, const StatusCode &sc) override
void google_before(const std::string &s) override
Start the google tool.
void afterFinalize(INamedInterface *i) override
StatusCode initialize() override
Initialize the auditor base.
Base for Google Auditors.
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
void beforeExecute(INamedInterface *i) override
virtual void google_after(const std::string &s)=0
stop the google tool
void after(CustomEventTypeRef type, INamedInterface *i, const StatusCode &sc) override
Auditor using the Google CPU Profiler.
bool alreadyRunning() override
check if we are already running the tool
const std::string & name() const override
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
virtual const std::string & name() const =0
Retrieve the name of the instance.
The interface implemented by the IncidentSvc service.
void after(StandardEventType type, INamedInterface *i, const StatusCode &sc) override
bool isComponentEnabled(const std::string &name) const
Check if auditing is enabled for the given component.
Auditor based on the Google Heap Profiler.
void afterEndRun(INamedInterface *i) override
bool isSequencer(INamedInterface *i) const
Check if the component in question is a GaudiSequencer or a Sequencer.
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Gaudi::Property< std::vector< std::string > > m_veto