ATLAS Offline Software
MemoryMonitorModule.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 
8 
9 //
10 // includes
11 //
12 
14 
15 #include <EventLoop/ModuleData.h>
16 #include <TSystem.h>
17 
18 //
19 // method implementations
20 //
21 
22 namespace EL
23 {
24  namespace Detail
25  {
27  firstInitialize (ModuleData& /*data*/)
28  {
29  ANA_CHECK (printMemoryUsage ("firstInitialize"));
30  return StatusCode::SUCCESS;
31  }
32 
33 
34 
36  onInitialize (ModuleData& /*data*/)
37  {
38  ANA_CHECK (printMemoryUsage ("onInitialize"));
39  return StatusCode::SUCCESS;
40  }
41 
42 
43 
45  onExecute (ModuleData& /*data*/)
46  {
47  if (++ m_numExecute == m_executeNext)
48  {
51  m_executeStep *= 10, m_executeTarget *= 10;
52 
53  ANA_CHECK (printMemoryUsage ("onExecute(" + std::to_string (m_numExecute) + ")"));
54  }
55  return StatusCode::SUCCESS;
56  }
57 
58 
59 
61  postFirstEvent (ModuleData& /*data*/)
62  {
63  ANA_CHECK (printMemoryUsage ("postFirstEvent"));
64  return StatusCode::SUCCESS;
65  }
66 
67 
68 
70  onFinalize (ModuleData& /*data*/)
71  {
72  ANA_CHECK (printMemoryUsage ("onFinalize"));
73  return StatusCode::SUCCESS;
74  }
75 
76 
77 
79  onWorkerEnd (ModuleData& /*data*/)
80  {
81  ANA_CHECK (printMemoryUsage ("onWorkerEnd"));
82  return StatusCode::SUCCESS;
83  }
84 
85 
86 
88  printMemoryUsage (const std::string& location)
89  {
90  ::ProcInfo_t pinfo;
91  if (gSystem->GetProcInfo (&pinfo) != 0) {
92  ANA_MSG_ERROR ("Could not get memory usage information");
93  return StatusCode::FAILURE;
94  }
95  ANA_MSG_INFO ("Memory usage at " << location << ": " << pinfo.fMemResident << " kB resident, " << pinfo.fMemVirtual << " kB virtual");
96  lastRSS = pinfo.fMemResident;
97  return StatusCode::SUCCESS;
98  }
99  }
100 }
EL::Detail::MemoryMonitorModule::printMemoryUsage
StatusCode printMemoryUsage(const std::string &location)
Definition: MemoryMonitorModule.cxx:88
EL::Detail::ModuleData
the data the EventLoop core classes are sharing with the Module implementation
Definition: ModuleData.h:64
EL::Detail::MemoryMonitorModule::m_executeStep
std::uint64_t m_executeStep
Definition: MemoryMonitorModule.h:64
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
EL::Detail::MemoryMonitorModule::firstInitialize
virtual StatusCode firstInitialize(ModuleData &data) override
action at the the very beginning of the worker job
Definition: MemoryMonitorModule.cxx:27
EL::Detail::MemoryMonitorModule::m_executeNext
std::uint64_t m_executeNext
Definition: MemoryMonitorModule.h:63
EL::Detail::MemoryMonitorModule::m_executeTarget
std::uint64_t m_executeTarget
Definition: MemoryMonitorModule.h:65
EL::Detail::MemoryMonitorModule::m_numExecute
std::uint64_t m_numExecute
Definition: MemoryMonitorModule.h:62
MemoryMonitorModule.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ANA_MSG_INFO
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:290
EL::Detail::MemoryMonitorModule::onExecute
virtual StatusCode onExecute(ModuleData &data) override
actions just before execute is called on algorithms
Definition: MemoryMonitorModule.cxx:45
EL
This module defines the arguments passed from the BATCH driver to the BATCH worker.
Definition: AlgorithmWorkerData.h:24
EL::Detail::MemoryMonitorModule::postFirstEvent
virtual StatusCode postFirstEvent(ModuleData &data) override
action after processing first event
Definition: MemoryMonitorModule.cxx:61
EL::Detail::MemoryMonitorModule::onWorkerEnd
virtual StatusCode onWorkerEnd(ModuleData &data) override
action at the end of the worker job
Definition: MemoryMonitorModule.cxx:79
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
xAOD::DiTauJetParameters::Detail
Detail
Definition: DiTauDefs.h:38
EL::Detail::MemoryMonitorModule::onFinalize
virtual StatusCode onFinalize(ModuleData &data) override
actions just before algorithms are finalized
Definition: MemoryMonitorModule.cxx:70
EL::Detail::MemoryMonitorModule::lastRSS
std::optional< std::uint64_t > lastRSS
the last RSS value read
Definition: MemoryMonitorModule.h:54
ModuleData.h
EL::Detail::MemoryMonitorModule::onInitialize
virtual StatusCode onInitialize(ModuleData &data) override
action just before algorithms are initialized
Definition: MemoryMonitorModule.cxx:36