16 int mallctl(
const char *
name,
void *oldp,
size_t *oldlenp,
void *newp,
size_t newlen);
29 base_class(name, svcLoc), m_eventNumber(0), m_startFromIncidents({}),
30 m_stopAtIncidents({}), m_hasStartIncident(
false), m_hasStopIncident(
false),
33 declareProperty(
"StartFromEventN", m_nStartFromEvent = 0,
34 "After what event we start profiling. "
37 declareProperty(
"StartFromIncidents", m_startFromIncidents = {},
38 "Incidents that trigger profiling start"
41 declareProperty(
"StopAtEventN", m_nStopAtEvent = 0,
42 "After what event we stop profiling. "
43 "If 0 than we also profile finalization stage. Default = 0."
46 declareProperty(
"StopAtIncidents", m_stopAtIncidents = {},
47 "Incidents that trigger profiling start"
50 declareProperty(
"DumpPeriod", m_dumpPeriod = 100,
51 "Period for dumping head to a file. Default=100"
64 static const std::string serviceName =
"IncidentSvc";
67 error() <<
"Cannot retrieve " << serviceName <<
endmsg;
95 info() <<
"Stop profiling trigger was specified but no start. Defaulting to first events" <<
endmsg;
111 return base_class::finalize();
122 if (IncidentType::BeginEvent == incident.
type())
125 }
else if (IncidentType::EndEvent == incident.
type())
135 if (startincident == incident.
type())
137 info() <<
"Starting Jemalloc profile at incident "
150 if (stopincident == incident.
type())
152 info() <<
"Stopping Jemalloc profile at incident "
203 info() <<
"Starting Jemalloc profile at event "
205 mallctl(
"prof.dump", NULL, NULL, NULL, 0);
222 info() <<
"Dumping Jemalloc profile at event "
224 mallctl(
"prof.dump", NULL, NULL, NULL, 0);
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
StatusCode initialize()
Initializer.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
const std::string & type() const
Access to the incident type.
void startProfiling()
Utility method to start profiling with jemalloc.
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
StatusCode finalize()
Finalizer.
Service that enables the Jemalloc profiler on demand.
std::vector< std::string > m_stopAtIncidents
virtual ~JemallocProfileSvc()
bool isFailure() const
Test for a status code of FAILURE.
int mallctl(const char *name, void *oldp, size_t *oldlenp, void *newp, size_t newlen)
#define DECLARE_COMPONENT(type)
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
void stopProfiling()
Utility method to stop profiling with jemalloc.
std::vector< std::string > m_startFromIncidents
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Base class for all Incidents (computing events).
virtual void addListener(IIncidentListener *lis, const std::string &type="", long priority=0, bool rethrow=false, bool singleShot=false)=0
Add listener.
void dumpProfile()
Utility method to dump profile with jemalloc.
SmartIF< IIncidentSvc > m_incidentSvc
Pointer to the incident service.
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
virtual void removeListener(IIncidentListener *lis, const std::string &type="")=0
Remove listener.
JemallocProfileSvc(const std::string &name, ISvcLocator *svcLoc)
Standard constructor.
int m_nStartFromEvent
Start, End event and counter.
void handle(const Incident &incident)
Destructor.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
bool m_profiling
Status of the profiling.