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" 43 using extends::extends;
52 inSvc->addListener(
this, IncidentType::BeginEvent );
92 return ( dynamic_cast<GaudiSequencer*>( i ) != NULL || dynamic_cast<Sequencer*>( i ) != NULL );
109 t << name <<
"-" <<
type;
110 if ( type ==
"Execute" ) t <<
"-Event" <<
m_nEvts;
121 if ( IncidentType::BeginEvent == incident.
type() ) {
156 info() <<
"Starting Auditor for " << s <<
":" << type <<
endmsg;
160 warning() <<
"Auditor already running. Cannot be started for " << s <<
endmsg;
222 {
"Initialize",
"ReInitialize",
"Execute",
"BeginRun",
"EndRun",
"Finalize"},
223 "List of phases to activate the Auditoring during"};
225 this,
"DisableFor", {},
"List of component names to disable the auditing for"};
227 this,
"EnableFor", {},
"Any component in this list will be audited. If empty, all will be done."};
230 this,
"DoFullEventProfile",
false,
231 "If true, instead of individually auditing components, the full event (or events) will be audited in one go"};
233 this,
"FullEventNSampleEvents", 1,
"The number of events to include in a full event audit, if enabled"};
235 "Number of events to skip before activating the auditing"};
237 "If true, auditing will be skipped for Sequencer objects."};
264 using AuditorBase::AuditorBase;
270 if ( m_dumpProfileHeaps ) { HeapProfilerDump( s.
c_str() ); }
271 if ( m_printProfilesToLog ) {
272 const char* profile = GetHeapProfile();
303 using AuditorBase::AuditorBase;
309 const char* HEAPCHECK = getenv(
"HEAPCHECK" );
311 fatal() <<
"Environment variable HEAPCHECK must be set to 'local'" <<
endmsg;
315 warning() <<
"Environment variable HEAPCHECK is set to " << HEAPCHECK
316 <<
" Partial Program Heap Checking is disabled" <<
endmsg;
325 if ( m_enabled && !m_checker ) { m_checker.reset(
new HeapLeakChecker( s.
c_str() ) ); }
329 if ( m_enabled && m_checker ) {
330 if ( !m_checker->NoLeaks() ) {
warning() <<
"Leak detected for " << s <<
endmsg; }
338 bool m_enabled =
true;
358 using AuditorBase::AuditorBase;
364 ProfilerStart( ( s +
".prof" ).c_str() );
378 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.
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
constexpr static const auto SUCCESS
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
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
constexpr static const auto FAILURE
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