diff --git a/Control/AthenaAuditors/src/AthMemoryAuditor.cxx b/Control/AthenaAuditors/src/AthMemoryAuditor.cxx index a3b8fff21f2233ae53f81f04eb424f83d38232d2..3b1e38199905a0aa5f2105b1b8a3a8b6f6bfb000 100644 --- a/Control/AthenaAuditors/src/AthMemoryAuditor.cxx +++ b/Control/AthenaAuditors/src/AthMemoryAuditor.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ @@ -55,11 +55,6 @@ AthMemoryAuditor::AthMemoryAuditor( const std::string& name, current_stage=1; } -AthMemoryAuditor::~AthMemoryAuditor() -{ - ATH_MSG_DEBUG("In Destructor"); -} - StatusCode AthMemoryAuditor::finalize() { @@ -632,85 +627,14 @@ std::string AthMemoryAuditor::stageToString(long s) return str; } -void AthMemoryAuditor::beforeInitialize(INamedInterface* comp) -{ - // ATH_MSG_INFO("==> beforeInitialize " << comp->name() << " . " << initialized ); - context=(uintptr_t)(&(comp->name())); - - stacktraceDepth=m_defaultStacktraceDepth; - auto fit=arrayAlgIndex.find(comp->name()); - if ( fit == arrayAlgIndex.end() ) - { - // this allocation would show up as memory leak - suppress later printout by setting stage to zero - current_stage=0; - collectStacktraces=false; - arrayAlgIndex[comp->name()]=aiStruct(curIndex= ++curMaxIndex,m_defaultStacktraceDepth); - } - else - { - curIndex=fit->second.index; - stacktraceDepth=fit->second.stacktrace; - } - algorithms[curIndex]=comp->name(); - current_stage=3; -} - -void AthMemoryAuditor::beforeReinitialize(INamedInterface* comp) -{ - context=(uintptr_t)(&(comp->name())); - - stacktraceDepth=m_defaultStacktraceDepth; - auto fit=arrayAlgIndex.find(comp->name()); - if ( fit == arrayAlgIndex.end() ) - { - // this allocation would show up as memory leak - suppress later printout by setting stage to zero - current_stage=0; - collectStacktraces=false; - arrayAlgIndex[comp->name()]=aiStruct(curIndex= ++curMaxIndex,m_defaultStacktraceDepth); - } - else - { - curIndex=fit->second.index; - stacktraceDepth=fit->second.stacktrace; - } - algorithms[curIndex]=comp->name(); - current_stage=4; - collectStacktraces=bool(stacktraceDepth); -} - -void AthMemoryAuditor::beforeExecute(INamedInterface* comp) +void AthMemoryAuditor::before(StandardEventType evt, INamedInterface* comp) { - stacktraceDepth=m_defaultStacktraceDepth; - auto fit=arrayAlgIndex.find(comp->name()); - if ( fit == arrayAlgIndex.end() ) - { - // this allocation would show up as memory leak - suppress later printout by setting stage to zero - current_stage=0; - collectStacktraces=false; - arrayAlgIndex[comp->name()]=aiStruct(curIndex= ++curMaxIndex,m_defaultStacktraceDepth); - } - else - { - curIndex=fit->second.index; - stacktraceDepth=fit->second.stacktrace; - } - algorithms[curIndex]=comp->name(); - - if(current_stage<1E6) - current_stage=1E6; - - context=(uintptr_t)(&(comp->name())); - - if (context && ( contextFirst == context ) ) - ++current_stage; - - if (context && ( contextFirst == 0 ) ) - contextFirst = context; - collectStacktraces=bool(stacktraceDepth); -} + // Only handle these event types + if ( evt!=IAuditor::Initialize && evt!=IAuditor::ReInitialize && + evt!=IAuditor::Execute && evt!=IAuditor::Finalize ) { + return; + } -void AthMemoryAuditor::beforeFinalize(INamedInterface* comp) -{ context=(uintptr_t)(&(comp->name())); stacktraceDepth=m_defaultStacktraceDepth; @@ -728,33 +652,37 @@ void AthMemoryAuditor::beforeFinalize(INamedInterface* comp) stacktraceDepth=fit->second.stacktrace; } algorithms[curIndex]=comp->name(); - current_stage=1E8-2; - collectStacktraces=bool(stacktraceDepth); -} -void AthMemoryAuditor::afterInitialize(INamedInterface* /* comp */) -{ - curIndex=1; - stacktraceDepth=m_defaultStacktraceDepth; - collectStacktraces=bool(m_defaultStacktraceDepth); -} - -void AthMemoryAuditor::afterReinitialize(INamedInterface* /* comp */) -{ - curIndex=1; - stacktraceDepth=m_defaultStacktraceDepth; - collectStacktraces=bool(m_defaultStacktraceDepth); + if (evt==IAuditor::Initialize) { + current_stage=3; + } + else if (evt==IAuditor::ReInitialize) { + current_stage=4; + collectStacktraces=bool(stacktraceDepth); + } + else if (evt==IAuditor::Execute) { + if(current_stage<1E6) + current_stage=1E6; + if (context && ( contextFirst == context ) ) + ++current_stage; + if (context && ( contextFirst == 0 ) ) + contextFirst = context; + collectStacktraces=bool(stacktraceDepth); + } + else if (evt==IAuditor::Finalize) { + current_stage=1E8-2; + collectStacktraces=bool(stacktraceDepth); + } } -void AthMemoryAuditor::afterExecute(INamedInterface* /* comp */, const StatusCode& /* sc */) +void AthMemoryAuditor::after(StandardEventType evt, INamedInterface*, const StatusCode&) { - curIndex=1; - stacktraceDepth=m_defaultStacktraceDepth; - collectStacktraces=bool(m_defaultStacktraceDepth); -} + // Only handle these event types + if ( evt!=IAuditor::Initialize && evt!=IAuditor::ReInitialize && + evt!=IAuditor::Execute && evt!=IAuditor::Finalize ) { + return; + } -void AthMemoryAuditor::afterFinalize(INamedInterface* /* comp */) -{ curIndex=1; stacktraceDepth=m_defaultStacktraceDepth; collectStacktraces=bool(m_defaultStacktraceDepth); diff --git a/Control/AthenaAuditors/src/AthMemoryAuditor.h b/Control/AthenaAuditors/src/AthMemoryAuditor.h index 3d124e0069300fb4e2a5eb26ad66dfb43670c03c..b4f372cbf409b59ffc59746a846f8ab55a1e6bd4 100644 --- a/Control/AthenaAuditors/src/AthMemoryAuditor.h +++ b/Control/AthenaAuditors/src/AthMemoryAuditor.h @@ -1,7 +1,7 @@ ///////////////////////// -*- C++ -*- ///////////////////////////// /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ // AthMemoryAuditor.h @@ -22,12 +22,8 @@ ATLAS_NO_CHECK_FILE_THREAD_SAFETY; // FrameWork includes #include "GaudiKernel/Auditor.h" -#include "GaudiKernel/ServiceHandle.h" -#include "GaudiKernel/MsgStream.h" #include "AthenaBaseComps/AthMessaging.h" -// #include <time.h> - // Forward declaration class INamedInterface; @@ -37,45 +33,27 @@ class AthMemoryAuditor : virtual public Auditor, public AthMessaging using Auditor::after; using AthMessaging::msg; -public: - +public: + /// Constructor AthMemoryAuditor(const std::string& name, ISvcLocator* pSvcLocator); - /// Destructor - virtual ~AthMemoryAuditor(); - - virtual StatusCode initialize(); - - virtual StatusCode finalize(); - - virtual void beforeInitialize(INamedInterface* alg); - virtual void beforeReinitialize(INamedInterface* alg); - virtual void beforeExecute(INamedInterface* alg); - virtual void beforeFinalize(INamedInterface* alg); - - // add after* hooks to reset name of algorithm to "framework" - virtual void afterInitialize(INamedInterface* alg); - virtual void afterReinitialize(INamedInterface* alg); - virtual void afterExecute(INamedInterface* alg, const StatusCode& sc); - virtual void afterFinalize(INamedInterface* alg); - - bool m_reported; + virtual StatusCode initialize() override; + virtual StatusCode finalize() override; + virtual void before(StandardEventType evt, INamedInterface* comp) override; + virtual void after(StandardEventType evt, INamedInterface* comp, const StatusCode& sc) override; static bool m_usetcmalloc; -private: +private: + bool m_reported; int m_stmax; - int m_defaultStacktraceDepth; - std::vector<std::string> m_depthPerAlg; void report (); - std::string stageToString(long); - uint64_t sum(uint32_t a, uint32_t b) { return ((((uint64_t)a)<<32) + b); }; }; #endif //> ATHENASERVICES_ATHMEMORYAUDITOR_H diff --git a/Control/AthenaAuditors/src/CoWAuditor.cxx b/Control/AthenaAuditors/src/CoWAuditor.cxx deleted file mode 100644 index 93521546d11ed1cbe06b630747825c5cbb16d7aa..0000000000000000000000000000000000000000 --- a/Control/AthenaAuditors/src/CoWAuditor.cxx +++ /dev/null @@ -1,389 +0,0 @@ -/* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration -*/ - -#include "CoWAuditor.h" -#include "GaudiKernel/INamedInterface.h" -#include <algorithm> -#include "GaudiKernel/IIncidentSvc.h" -#include "GaudiKernel/ITHistSvc.h" -#include <chrono> - -CoWAuditor::CoWAuditor( const std::string& name, - ISvcLocator* pSvcLocator ) : - Auditor ( name, pSvcLocator ), - AthMessaging(msgSvc(), name), - m_dumpFinalize(true),m_dumpInfo(true),m_detailed(false),m_streamName("CoWMoO.root"),m_hashTree(0),m_snapshotTree(0), - m_algId(0),m_vmem(0),m_rss(0),m_pss(0),m_shared(0),m_private(0),m_anon(0),m_swap(0),m_currTime(0) -{ - // - // Property declaration - // - declareProperty( "DumpAtFinalize", m_dumpFinalize, "Dump statistics at finalize (true)" ); - declareProperty( "DetailedDump", m_detailed, "Dump per library details(false)" ); - declareProperty( "DumpAll", m_dumpInfo, "Dump delta for every call (true)" ); - declareProperty( "MonFile", m_streamName, "output file name (CoWMoO.root)" ); -} - -CoWAuditor::~CoWAuditor() -{ - //m_msg << MSG::DEBUG << "Calling destructor" << endmsg; - delete m_hashTree; - delete m_snapshotTree; -} - -StatusCode CoWAuditor::initialize() -{ - // if(m_detailed){ - // m_detailedStack.reserve(200);//200 deep stack - // }else{ - m_summaryStack.reserve(200);//200 deep stack - // } - IIncidentSvc* incsvc; - - if (StatusCode::SUCCESS!=service("IncidentSvc",incsvc)) { - ATH_MSG_FATAL( "Incident service not found"); - return StatusCode::FAILURE; - } - incsvc->addListener(this,"PreFork", -500); - incsvc->addListener(this,"PostFork",10000); - m_snapshotTree=new TTree("Snapshots","Smaps aggregated snapshots for given algorithm"); - m_snapshotTree->Branch("algID",&m_algId,"algID/l"); - m_snapshotTree->Branch("vmem",&m_vmem,"vmem/L"); - m_snapshotTree->Branch("rss",&m_rss,"rss/L"); - m_snapshotTree->Branch("pss",&m_pss,"pss/L"); - m_snapshotTree->Branch("shared",&m_shared,"shared/L"); - m_snapshotTree->Branch("private",&m_private,"private/L"); - m_snapshotTree->Branch("anon",&m_anon,"anon/L"); - m_snapshotTree->Branch("swap",&m_swap,"swap/L"); - m_snapshotTree->Branch("time",&m_currTime,"time/l"); - //THistSvc does not work for root histograms need another solution - //Disabling registration for the time being - // ServiceHandle<ITHistSvc> thistSvc("THistSvc",name()); - // thistSvc->regTree(m_streamName+"/Snapshots",m_snapshotTree); - return StatusCode::SUCCESS; - -} - -StatusCode CoWAuditor::finalize() -{ - if(m_dumpFinalize){ - ATH_MSG_INFO("CoW stats Summary"); - char buff [1000]; - std::stringstream oss; - snprintf(buff,1000,"%28s\t| %8s | %8s | %8s | %8s | %8s | %8s | %8s |", - "Name","VMem","RSS","PSS","Shared","Private","Swap","Anon"); - ATH_MSG_INFO(buff); - typedef std::pair<std::string,CoWTools::CoWRecordStats> pair_t; - std::vector< pair_t > sortedStack; - sortedStack.reserve(m_runTotals.size()); - for(auto it=m_runTotals.begin();it!=m_runTotals.end();++it){ - sortedStack.push_back(std::make_pair(it->first,it->second)); - } - std::sort(sortedStack.begin(),sortedStack.end(),[](const pair_t &a,const pair_t &b){return (a.second)<(b.second);}); - for(auto it=sortedStack.begin();it!=sortedStack.end();++it){ - oss.str(""); - oss<<it->second; - snprintf(buff,1000,"%-28s\t: %s",it->first.c_str(),oss.str().c_str()); - ATH_MSG_INFO(buff); - } - } - std::string algName; - std::size_t algHash; - m_hashTree=new TTree("HashTable","Lookup table from hash to alg name"); - m_hashTree->Branch("algHash",&algHash,"algHash/l"); - m_hashTree->Branch("algName",&algName); - // ServiceHandle<ITHistSvc> thistSvc("THistSvc",name()); - // thistSvc->regTree(m_streamName+"/hashes",m_hashTree); - - //register tree! - for(auto& h:m_algHashes){ - algName=h.first; - algHash=h.second; - m_hashTree->Fill(); - } - m_hashTree->Write(); - m_snapshotTree->Write(); - return StatusCode::SUCCESS; -} - -void CoWAuditor::beforeInitialize(INamedInterface* comp) -{ - ATH_MSG_VERBOSE("Running for "<<comp->name()); - pushStats(comp->name()); -} - -void CoWAuditor::afterInitialize(INamedInterface* comp) -{ - ATH_MSG_VERBOSE("Running for "<<comp->name()); - popStats(comp->name()); -} - -void CoWAuditor::beforeReinitialize(INamedInterface* comp) -{ - ATH_MSG_VERBOSE("Running for "<<comp->name()); - pushStats(comp->name()); -} - -void CoWAuditor::afterReinitialize( INamedInterface* comp) -{ - ATH_MSG_VERBOSE("Running for "<<comp->name()); - popStats(comp->name()); -} - -void CoWAuditor::beforeExecute(INamedInterface* comp) -{ - ATH_MSG_VERBOSE("Running for "<<comp->name()); - pushStats(comp->name()); -} - -void CoWAuditor::afterExecute( INamedInterface* comp, - const StatusCode& ) -{ - ATH_MSG_VERBOSE("Running for "<<comp->name()); - popStats(comp->name()); -} - -void CoWAuditor::beforeFinalize(INamedInterface* comp) -{ - ATH_MSG_VERBOSE("Running for "<<comp->name()); - pushStats(comp->name()); -} - -void CoWAuditor::afterFinalize(INamedInterface* comp) -{ - ATH_MSG_VERBOSE("Running for "<<comp->name()); - popStats(comp->name()); -} - -void CoWAuditor::before(CustomEventTypeRef evt, - const std::string& caller) -{ - ATH_MSG_VERBOSE("Running before for "<<caller<<" with event "<<evt); - pushStats(caller); -} - -void CoWAuditor::after(CustomEventTypeRef evt, - const std::string& caller, - const StatusCode&) -{ - ATH_MSG_VERBOSE("Running after for "<<caller<<" with event "<<evt); - popStats(caller); -} - -bool CoWAuditor::pushStats(const std::string& caller){ - if(m_detailed){ - auto first=parseDetailedSmaps(); - if(first){ - m_detailedStack.push_back(first); - }else{ - ATH_MSG_ERROR("Parsing smaps failed while pushing for "<<caller); - return false; - } - }else{ - auto first=parseSmaps(); - if(first){ - first->m_libName=caller; - m_summaryStack.push_back(first); - }else{ - ATH_MSG_ERROR("Parsing smaps failed while pushing for "<<caller); - return false; - } - } - return true; -} - -bool CoWAuditor::popStats(const std::string& caller){ - if(m_detailed){ - auto last=parseDetailedSmaps(); - if(m_detailedStack.empty()){ - ATH_MSG_ERROR("Popping detail stack failed for caller="<<caller); - return false; - } - auto first=m_detailedStack.back(); - m_detailedStack.pop_back(); - if(last){ - diffDetailedMaps(last,first); - if(checkChange(last)){ - if(m_dumpInfo){ - std::stringstream oss; - int count=0; - for(auto l:*last){ - if(*(l.second)){ - count++; - oss<<*(l.second)<<std::endl; - } - } - msg(MSG::INFO)<<caller<<" : Total libs="<<count<<" stack depth="<<m_detailedStack.size()<<std::endl - <<oss.str()<<endmsg; - } - } - }else{ - ATH_MSG_ERROR("Parsing smaps failed for caller="<<caller); - return false; - } - }else{//do summary - auto last=parseSmaps(); - if(m_summaryStack.empty()){ - ATH_MSG_ERROR("Popping summary stack failed while popping for "<<caller); - return false; - } - auto first=m_summaryStack.back(); - m_summaryStack.pop_back(); - if(last){ - auto delta=(last->m_ms-first->m_ms); - if(delta){ - for(auto& it:m_summaryStack){ - it->m_ms+=delta; - } - auto it=m_algHashes.insert(std::make_pair(caller,m_hasher(caller))); - if(it.second){ - auto hit= m_existingHashes.insert(it.first->second); - if(!hit.second){ - m_existingHashes.insert((it.first->second<<1)); - } - it.first->second=((it.first->second)<<1); - } - auto vals=delta.getValueArray(); - m_vmem=vals[0]; - m_rss=vals[1]; - m_pss=vals[2]; - m_shared=vals[3]+vals[4]; - m_private=vals[5]+vals[6]; - m_anon=vals[8]; - m_swap=vals[10]; - m_algId=it.first->second; - m_currTime=std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now().time_since_epoch()).count(); - m_snapshotTree->Fill(); - if(m_dumpInfo){ - msg(MSG::INFO)<<caller<<" : "<<delta<<" oldName="<<first->m_libName<<" stack depth="<<m_summaryStack.size()<<endmsg; - } - - auto prev=m_runTotals.find(caller); - if(prev!=m_runTotals.end()){ - prev->second += delta; - }else{ - m_runTotals.insert(std::make_pair(caller,delta)); - } - } - }else{ - ATH_MSG_ERROR("Parsing smaps failed!"); - return false; - } - } - return true; -} - -std::shared_ptr<CoWAuditor::LibMap_t> CoWAuditor::parseDetailedSmaps(){ - auto lmap=std::make_shared<CoWAuditor::LibMap_t>(); - std::ifstream pfile("/proc/self/smaps"); - if(pfile.is_open()){ - std::string line; - std::stringstream ss; - while(!std::getline(pfile,line).eof()){ - if(line.empty())continue; - if(line.size()>30 && line.at(0)!='V'&& ss.str().size()!=0){ - ss.seekg(0); - //std::cout<<"Ss "<<ss.str()<<" size="<<ss.str().size()<<std::endl; - - auto lib=CoWTools::CoWLibrary::fromRecord(ss,true); - auto l=lmap->find(lib->m_libName); - if(l==lmap->end()){ - lmap->insert(std::make_pair(lib->m_libName,lib)); - }else{ - *(l->second)+=*lib; - } - ss.str(""); - ss.clear(); - // continue; - } - - ss<<line<<std::endl; - ss.clear(); - } - if(ss.str().size()>200){ - auto lib=CoWTools::CoWLibrary::fromRecord(ss,true); - auto l=lmap->find(lib->m_libName); - if(l==lmap->end()){ - lmap->insert(std::make_pair(lib->m_libName,lib)); - }else{ - *(l->second)+=*lib; - } - } - pfile.close(); - } - return lmap; - -} - -std::shared_ptr<CoWTools::CoWLibrary> CoWAuditor::parseSmaps(){ - std::ifstream pfile("/proc/self/smaps"); - std::shared_ptr<CoWTools::CoWLibrary> lr(0); - if(pfile.is_open()){ - std::string line; - std::stringstream ss; - std::string libName="Anonymous"; - lr=std::make_shared<CoWTools::CoWLibrary>(true); - while(!std::getline(pfile,line).eof()){ - if(line.empty())continue; - if(line.size()>30 && line.at(0)!='V' && ss.str().size()!=0){ - ss.seekg(0); - m_ms.parseRecord(ss); - //std::cout<<"MS ="<<ms<<std::endl; - lr->m_ms+=m_ms; - ss.str(""); - ss.clear(); - continue; - } - ss<<line<<std::endl; - ss.clear(); - } - //if there is any records left (should never be possible) - if(ss.str().size()>200){ - m_ms.parseRecord(ss); - lr->m_ms+=m_ms; - } - } - pfile.close(); - return lr; -} - -bool CoWAuditor::checkChange(std::shared_ptr<LibMap_t> &capture){ - for( auto l: *capture){ - if(*(l.second))return true; - } - return false; -} - -void CoWAuditor::diffDetailedMaps(std::shared_ptr<LibMap_t> &dst,std::shared_ptr<LibMap_t> &src){ - for( auto l: *src){ - auto old=dst->find(l.first); - if(old!=dst->end()){ - *(old->second)-=*(l.second); - }else{ - auto x=std::make_shared<CoWTools::CoWLibrary>(); - *x=-*(l.second); - dst->insert(std::make_pair(l.first,x)); - } - } -} - -void CoWAuditor::handle(const Incident &inc){ - ATH_MSG_INFO("Got incident "<<inc.type()<<" from "<<inc.source()); - if(!m_detailed){ - for( auto& i: m_summaryStack){ - auto v=i->m_ms.getValueArray(); - v[3]+=v[5]; - v[5]=0; - v[4]+=v[6]; - v[6]=0; - } - for(auto& i:m_runTotals){ - auto v=i.second.getValueArray(); - v[3]+=v[5]; - v[5]=0; - v[4]+=v[6]; - v[6]=0; - } - } -} diff --git a/Control/AthenaAuditors/src/CoWAuditor.h b/Control/AthenaAuditors/src/CoWAuditor.h deleted file mode 100644 index c690a7df0ed0d9aed2f7cebf179d6eaeacf5e857..0000000000000000000000000000000000000000 --- a/Control/AthenaAuditors/src/CoWAuditor.h +++ /dev/null @@ -1,122 +0,0 @@ -// --*- c++ -*-- - -/* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef ATHENAAUDITORS_COWAUDITOR -#define ATHENAAUDITORS_COWAUDITOR -#include <fstream> -#include <sstream> -#include <string> -#include <unordered_map> -#include <functional> -#include <unordered_set> -#include "CoWTools/CoWLibrary.h" -#include "GaudiKernel/Auditor.h" -#include "GaudiKernel/ServiceHandle.h" -#include "GaudiKernel/MsgStream.h" -#include "AthenaBaseComps/AthMessaging.h" -#include "GaudiKernel/IIncidentListener.h" -#include "TTree.h" - -class INamedInterface; -class Incident; - -class CoWAuditor : virtual public Auditor, public AthMessaging,public IIncidentListener -{ - using Auditor::before; - using Auditor::after; - using AthMessaging::msg; - - /////////////////////////////////////////////////////////////////// - // Public methods: - /////////////////////////////////////////////////////////////////// - public: - - /// Constructor - CoWAuditor(const std::string& name, ISvcLocator* pSvcLocator); - - /// Destructor - virtual ~CoWAuditor(); - - /// Gaudi hooks - virtual StatusCode initialize(); - - virtual StatusCode finalize(); - - /////////////////////////////////////////////////////////////////// - // Const methods: - /////////////////////////////////////////////////////////////////// - - /////////////////////////////////////////////////////////////////// - // Non-const methods: - /////////////////////////////////////////////////////////////////// - - virtual void beforeInitialize(INamedInterface* alg); - virtual void afterInitialize(INamedInterface* alg); - virtual void beforeReinitialize(INamedInterface* alg); - virtual void afterReinitialize(INamedInterface* alg); - virtual void beforeExecute(INamedInterface* alg); - virtual void afterExecute(INamedInterface* alg, const StatusCode&); - virtual void beforeFinalize(INamedInterface* alg); - virtual void afterFinalize(INamedInterface* alg); - - // custom event auditing... - - /// Audit the start of a custom "event". - virtual void before(IAuditor::CustomEventTypeRef evt, - INamedInterface* caller) - { return this->before (evt, caller->name()); } - - /** - * Audit the start of a custom "event" for callers that do not implement - * the @c INamedInterface. - */ - virtual void before (IAuditor::CustomEventTypeRef evt, - const std::string& caller); - - /// Audit the end of a custom "event". - virtual void after (IAuditor::CustomEventTypeRef evt, - INamedInterface* caller, - const StatusCode& sc) - { return this->after (evt, caller->name(), sc); } - - /** - * Audit the end of a custom "event" for callers that do not implement - * the @c INamedInterface. - */ - virtual void after (CustomEventTypeRef evt, const std::string& caller, - const StatusCode& sc); - - virtual void handle(const Incident&); - - /////////////////////////////////////////////////////////////////// - // Private data: - /////////////////////////////////////////////////////////////////// - private: - typedef std::unordered_map<std::string,std::shared_ptr<CoWTools::CoWLibrary> > LibMap_t; - bool checkChange(std::shared_ptr<LibMap_t> &capture); - void diffDetailedMaps(std::shared_ptr<LibMap_t> &dst,std::shared_ptr<LibMap_t> &src); - bool m_dumpFinalize,m_dumpInfo,m_detailed; - std::string m_streamName; - LibMap_t m_libMap; - std::vector<std::shared_ptr<CoWTools::CoWLibrary> > m_summaryStack; - std::vector<std::shared_ptr<LibMap_t> > m_detailedStack; - bool pushStats(const std::string&); - bool popStats(const std::string&); - std::shared_ptr<LibMap_t> parseDetailedSmaps(); - std::shared_ptr<CoWTools::CoWLibrary> parseSmaps(); - std::unordered_map<std::string,CoWTools::CoWRecordStats> m_runTotals; - std::unordered_set<std::size_t> m_existingHashes;//for potential collisions - std::unordered_map<std::string,std::size_t> m_algHashes; - TTree *m_hashTree; - TTree *m_snapshotTree; - std::size_t m_algId; - long m_vmem,m_rss,m_pss,m_shared,m_private,m_anon,m_swap; - ULong64_t m_currTime; - std::hash<std::string> m_hasher; - CoWTools::CoWRecordStats m_ms; -}; - -#endif diff --git a/Control/AthenaAuditors/src/FPEAuditor.cxx b/Control/AthenaAuditors/src/FPEAuditor.cxx index 414854bdb07c687a3bdb6c622e20bec33552ed26..35da7d97b3aef3104a21e1176e8b2ecbc76aef85 100644 --- a/Control/AthenaAuditors/src/FPEAuditor.cxx +++ b/Control/AthenaAuditors/src/FPEAuditor.cxx @@ -1,7 +1,7 @@ ///////////////////////// -*- C++ -*- ///////////////////////////// /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ // FPEAuditor.cxx @@ -153,47 +153,30 @@ void FPEAuditor::UninstallHandler() // fedisableexcept (FE_ALL_EXCEPT); } -void FPEAuditor::beforeInitialize(INamedInterface* /*comp*/) +void FPEAuditor::before(StandardEventType evt, INamedInterface*) { add_fpe_node(); -} - -void FPEAuditor::afterInitialize(INamedInterface* comp) -{ - //ATH_MSG_INFO("<== ini [" << comp->name() << "]"); - static const std::string step = "initialize"; - report_fpe(step, comp->name()); - pop_fpe_node(); - FPEAudit::lock_t lock (FPEAudit::s_mutex); - // CoreDumpSvc can also install a FPE handler, grrr. - if (comp->name() == "CoreDumpSvc") FPEAudit::s_handlerInstalled = false; - if ( m_NstacktracesOnFPE && ! FPEAudit::s_handlerInstalled ) - { - InstallHandler(); - m_nexceptions = m_NstacktracesOnFPE; + if ( evt==IAuditor::Execute ) { + if ( m_NstacktracesOnFPE && ! FPEAudit::s_handlerInstalled ) { + FPEAudit::lock_t lock (FPEAudit::s_mutex); + if ( m_NstacktracesOnFPE && ! FPEAudit::s_handlerInstalled ) { + InstallHandler(); + m_nexceptions = m_NstacktracesOnFPE; + } } - -} - -void FPEAuditor::beforeReinitialize(INamedInterface* /*comp*/) -{ - add_fpe_node(); + } } -void FPEAuditor::afterReinitialize( INamedInterface* comp) +void FPEAuditor::after(StandardEventType evt, INamedInterface* comp, const StatusCode&) { - static const std::string step = "reinitialize"; - report_fpe(step, comp->name()); + report_fpe(toStr(evt), comp->name()); pop_fpe_node(); -} -void FPEAuditor::beforeExecute(INamedInterface* /*comp*/) -{ - add_fpe_node(); - - if ( m_NstacktracesOnFPE && ! FPEAudit::s_handlerInstalled ) { + if ( evt==IAuditor::Initialize ) { FPEAudit::lock_t lock (FPEAudit::s_mutex); + // CoreDumpSvc can also install a FPE handler, grrr. + if (comp->name() == "CoreDumpSvc") FPEAudit::s_handlerInstalled = false; if ( m_NstacktracesOnFPE && ! FPEAudit::s_handlerInstalled ) { InstallHandler(); m_nexceptions = m_NstacktracesOnFPE; @@ -201,27 +184,7 @@ void FPEAuditor::beforeExecute(INamedInterface* /*comp*/) } } -void FPEAuditor::afterExecute( INamedInterface* comp, - const StatusCode& ) -{ - static const std::string step = "execute"; - report_fpe(step, comp->name()); - pop_fpe_node(); -} - -void FPEAuditor::beforeFinalize(INamedInterface* /*comp*/) -{ - add_fpe_node(); -} - -void FPEAuditor::afterFinalize(INamedInterface* comp) -{ - static const std::string step = "finalize"; - report_fpe(step, comp->name()); - pop_fpe_node(); -} - -void FPEAuditor::before(CustomEventTypeRef /*evt*/, +void FPEAuditor::before(CustomEventTypeRef /*evt*/, const std::string& /*caller*/) { add_fpe_node(); diff --git a/Control/AthenaAuditors/src/FPEAuditor.h b/Control/AthenaAuditors/src/FPEAuditor.h index 4c2572a1e765c3006d7bb8ff34c6a23860042b7a..3513ad65bef202f1410784b0aaad4409b264fb46 100644 --- a/Control/AthenaAuditors/src/FPEAuditor.h +++ b/Control/AthenaAuditors/src/FPEAuditor.h @@ -1,7 +1,7 @@ ///////////////////////// -*- C++ -*- ///////////////////////////// /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ // FPEAuditor.h @@ -51,22 +51,10 @@ class FPEAuditor : public AthCommonMsg<Auditor> virtual StatusCode finalize() override; - /////////////////////////////////////////////////////////////////// - // Const methods: - /////////////////////////////////////////////////////////////////// - - /////////////////////////////////////////////////////////////////// - // Non-const methods: - /////////////////////////////////////////////////////////////////// - virtual void beforeInitialize(INamedInterface* alg) override; - virtual void afterInitialize(INamedInterface* alg) override; - virtual void beforeReinitialize(INamedInterface* alg) override; - virtual void afterReinitialize(INamedInterface* alg) override; - virtual void beforeExecute(INamedInterface* alg) override; - virtual void afterExecute(INamedInterface* alg, const StatusCode&) override; - virtual void beforeFinalize(INamedInterface* alg) override; - virtual void afterFinalize(INamedInterface* alg) override; + // standard event auditing... + virtual void before(StandardEventType evt, INamedInterface* comp) override; + virtual void after(StandardEventType evt, INamedInterface* comp, const StatusCode& sc) override; // custom event auditing... diff --git a/Control/AthenaAuditors/src/components/AthenaAuditors_entries.cxx b/Control/AthenaAuditors/src/components/AthenaAuditors_entries.cxx index 2674f76ba71c31a9951b5e585cff0f263610860e..70ff58373913076879151a0303ef2413b7b68c22 100644 --- a/Control/AthenaAuditors/src/components/AthenaAuditors_entries.cxx +++ b/Control/AthenaAuditors/src/components/AthenaAuditors_entries.cxx @@ -1,8 +1,5 @@ #include "../FPEAuditor.h" -#include "../CoWAuditor.h" #include "../AthMemoryAuditor.h" DECLARE_COMPONENT( FPEAuditor ) -DECLARE_COMPONENT( CoWAuditor ) DECLARE_COMPONENT( AthMemoryAuditor ) -