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;
58 inSvc->addListener(
this, IncidentType::BeginEvent );
102 return ( dynamic_cast<GaudiSequencer*>( i ) != NULL || dynamic_cast<Sequencer*>( i ) != NULL );
122 t << name <<
"-" <<
type;
123 if ( type ==
"Execute" ) t <<
"-Event" <<
m_nEvts;
135 if ( IncidentType::BeginEvent == incident.
type() ) {
180 info() <<
"Starting Auditor for " << s <<
":" << type <<
endmsg;
184 warning() <<
"Auditor already running. Cannot be started for " << s <<
endmsg;
256 {
"Initialize",
"ReInitialize",
"Execute",
"BeginRun",
"EndRun",
"Finalize"},
257 "List of phases to activate the Auditoring during"};
259 this,
"DisableFor", {},
"List of component names to disable the auditing for"};
261 this,
"EnableFor", {},
"Any component in this list will be audited. If empty, all will be done."};
264 this,
"DoFullEventProfile",
false,
265 "If true, instead of individually auditing components, the full event (or events) will be audited in one go"};
267 this,
"FullEventNSampleEvents", 1,
"The number of events to include in a full event audit, if enabled"};
269 "Number of events to skip before activating the auditing"};
271 "If true, auditing will be skipped for Sequencer objects."};
299 using AuditorBase::AuditorBase;
306 if ( m_dumpProfileHeaps ) {
307 HeapProfilerDump( s.
c_str() );
309 if ( m_printProfilesToLog ) {
310 const char* profile = GetHeapProfile();
342 using AuditorBase::AuditorBase;
352 const char* HEAPCHECK = getenv(
"HEAPCHECK" );
354 fatal() <<
"Environment variable HEAPCHECK must be set to 'local'" <<
endmsg;
358 warning() <<
"Environment variable HEAPCHECK is set to " << HEAPCHECK
359 <<
" Partial Program Heap Checking is disabled" <<
endmsg;
369 if ( m_enabled && !m_checker ) {
370 m_checker.reset(
new HeapLeakChecker( s.
c_str() ) );
376 if ( m_enabled && m_checker ) {
377 if ( !m_checker->NoLeaks() ) {
387 bool m_enabled =
true;
408 using AuditorBase::AuditorBase;
415 ProfilerStart( ( s +
".prof" ).c_str() );
430 bool m_running =
false;
void afterReinitialize(INamedInterface *i) override
Gaudi::Property< std::vector< std::string > > m_list
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.
~AuditorBase() override=default
Destructor.
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.
bool isFailure() const
Test for a status code of FAILURE.
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
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
MSG::Level msgLevel() const
get the output level from the embedded MsgStream
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.
Gaudi::Property< std::vector< std::string > > m_veto