CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
edm::ZombieKillerService Class Reference

Public Member Functions

 ZombieKillerService (edm::ParameterSet const &, edm::ActivityRegistry &)
 

Static Public Member Functions

static void fillDescriptions (ConfigurationDescriptions &descriptions)
 

Private Member Functions

void checkForZombie ()
 
void notAZombieYet ()
 
void startThread ()
 
void stopThread ()
 

Private Attributes

const unsigned int m_checkThreshold
 
bool m_jobDone
 
std::condition_variable m_jobDoneCondition
 
std::mutex m_jobDoneMutex
 
std::atomic< unsigned int > m_numberChecksWhenNotAlive
 
const unsigned int m_secsBetweenChecks
 
std::atomic< bool > m_stillAlive
 
std::thread m_watchingThread
 

Detailed Description

Definition at line 27 of file ZombieKillerService.cc.

Constructor & Destructor Documentation

◆ ZombieKillerService()

ZombieKillerService::ZombieKillerService ( edm::ParameterSet const &  iPSet,
edm::ActivityRegistry iRegistry 
)

Definition at line 65 of file ZombieKillerService.cc.

66  : m_checkThreshold(iPSet.getUntrackedParameter<unsigned int>("numberOfAllowedFailedChecksInARow")),
67  m_secsBetweenChecks(iPSet.getUntrackedParameter<unsigned int>("secondsBetweenChecks")),
68  m_jobDone(false),
69  m_stillAlive(true),
71  iRegistry.watchPostBeginJob([this]() { startThread(); });
72  iRegistry.watchPostEndJob([this]() { stopThread(); });
73 
74  iRegistry.watchPreSourceRun([this](RunIndex) { notAZombieYet(); });
75  iRegistry.watchPostSourceRun([this](RunIndex) { notAZombieYet(); });
76 
77  iRegistry.watchPreSourceLumi([this](LuminosityBlockIndex) { notAZombieYet(); });
78  iRegistry.watchPostSourceLumi([this](LuminosityBlockIndex) { notAZombieYet(); });
79 
80  iRegistry.watchPreSourceEvent([this](StreamID) { notAZombieYet(); });
81  iRegistry.watchPostSourceEvent([this](StreamID) { notAZombieYet(); });
82 
83  iRegistry.watchPreModuleBeginStream([this](StreamContext const&, ModuleCallingContext const&) { notAZombieYet(); });
84  iRegistry.watchPostModuleBeginStream([this](StreamContext const&, ModuleCallingContext const&) { notAZombieYet(); });
85 
86  iRegistry.watchPreModuleEndStream([this](StreamContext const&, ModuleCallingContext const&) { notAZombieYet(); });
87  iRegistry.watchPostModuleEndStream([this](StreamContext const&, ModuleCallingContext const&) { notAZombieYet(); });
88 
89  iRegistry.watchPreModuleEndJob([this](ModuleDescription const&) { notAZombieYet(); });
90  iRegistry.watchPostModuleEndJob([this](ModuleDescription const&) { notAZombieYet(); });
91  iRegistry.watchPreModuleEvent([this](StreamContext const&, ModuleCallingContext const&) { notAZombieYet(); });
92  iRegistry.watchPostModuleEvent([this](StreamContext const&, ModuleCallingContext const&) { notAZombieYet(); });
93 
95  [this](StreamContext const&, ModuleCallingContext const&) { notAZombieYet(); });
97  [this](StreamContext const&, ModuleCallingContext const&) { notAZombieYet(); });
98 
99  iRegistry.watchPreModuleStreamEndRun([this](StreamContext const&, ModuleCallingContext const&) { notAZombieYet(); });
100  iRegistry.watchPostModuleStreamEndRun([this](StreamContext const&, ModuleCallingContext const&) { notAZombieYet(); });
101 
103  [this](StreamContext const&, ModuleCallingContext const&) { notAZombieYet(); });
105  [this](StreamContext const&, ModuleCallingContext const&) { notAZombieYet(); });
106 
107  iRegistry.watchPreModuleStreamEndLumi([this](StreamContext const&, ModuleCallingContext const&) { notAZombieYet(); });
109  [this](StreamContext const&, ModuleCallingContext const&) { notAZombieYet(); });
110 
112  [this](GlobalContext const&, ModuleCallingContext const&) { notAZombieYet(); });
114  [this](GlobalContext const&, ModuleCallingContext const&) { notAZombieYet(); });
115 
116  iRegistry.watchPreModuleGlobalEndRun([this](GlobalContext const&, ModuleCallingContext const&) { notAZombieYet(); });
117  iRegistry.watchPostModuleGlobalEndRun([this](GlobalContext const&, ModuleCallingContext const&) { notAZombieYet(); });
118 
120  [this](GlobalContext const&, ModuleCallingContext const&) { notAZombieYet(); });
122  [this](GlobalContext const&, ModuleCallingContext const&) { notAZombieYet(); });
123 
124  iRegistry.watchPreModuleGlobalEndLumi([this](GlobalContext const&, ModuleCallingContext const&) { notAZombieYet(); });
126  [this](GlobalContext const&, ModuleCallingContext const&) { notAZombieYet(); });
127 }

References notAZombieYet(), startThread(), stopThread(), edm::ActivityRegistry::watchPostBeginJob(), edm::ActivityRegistry::watchPostEndJob(), edm::ActivityRegistry::watchPostModuleBeginStream(), edm::ActivityRegistry::watchPostModuleEndJob(), edm::ActivityRegistry::watchPostModuleEndStream(), edm::ActivityRegistry::watchPostModuleEvent(), edm::ActivityRegistry::watchPostModuleGlobalBeginLumi(), edm::ActivityRegistry::watchPostModuleGlobalBeginRun(), edm::ActivityRegistry::watchPostModuleGlobalEndLumi(), edm::ActivityRegistry::watchPostModuleGlobalEndRun(), edm::ActivityRegistry::watchPostModuleStreamBeginLumi(), edm::ActivityRegistry::watchPostModuleStreamBeginRun(), edm::ActivityRegistry::watchPostModuleStreamEndLumi(), edm::ActivityRegistry::watchPostModuleStreamEndRun(), edm::ActivityRegistry::watchPostSourceEvent(), edm::ActivityRegistry::watchPostSourceLumi(), edm::ActivityRegistry::watchPostSourceRun(), edm::ActivityRegistry::watchPreModuleBeginStream(), edm::ActivityRegistry::watchPreModuleEndJob(), edm::ActivityRegistry::watchPreModuleEndStream(), edm::ActivityRegistry::watchPreModuleEvent(), edm::ActivityRegistry::watchPreModuleGlobalBeginLumi(), edm::ActivityRegistry::watchPreModuleGlobalBeginRun(), edm::ActivityRegistry::watchPreModuleGlobalEndLumi(), edm::ActivityRegistry::watchPreModuleGlobalEndRun(), edm::ActivityRegistry::watchPreModuleStreamBeginLumi(), edm::ActivityRegistry::watchPreModuleStreamBeginRun(), edm::ActivityRegistry::watchPreModuleStreamEndLumi(), edm::ActivityRegistry::watchPreModuleStreamEndRun(), edm::ActivityRegistry::watchPreSourceEvent(), edm::ActivityRegistry::watchPreSourceLumi(), and edm::ActivityRegistry::watchPreSourceRun().

Member Function Documentation

◆ checkForZombie()

void ZombieKillerService::checkForZombie ( )
private

Definition at line 158 of file ZombieKillerService.cc.

158  {
159  if (not m_stillAlive) {
162  edm::LogError("JobStuck") << "Too long since the job has last made progress.";
163  std::terminate();
164  } else {
165  edm::LogWarning("JobProgressing") << "It has been " << m_numberChecksWhenNotAlive * m_secsBetweenChecks
166  << " seconds since job seen progressing";
167  }
168  }
169  m_stillAlive = false;
170 }

References m_checkThreshold, m_numberChecksWhenNotAlive, m_secsBetweenChecks, and m_stillAlive.

Referenced by startThread().

◆ fillDescriptions()

void ZombieKillerService::fillDescriptions ( ConfigurationDescriptions descriptions)
static

Definition at line 192 of file ZombieKillerService.cc.

192  {
194  desc.addUntracked<unsigned int>("secondsBetweenChecks", 60)
195  ->setComment("Number of seconds to wait between checking if progress has been made.");
196  desc.addUntracked<unsigned int>("numberOfAllowedFailedChecksInARow", 3)
197  ->setComment("Number of allowed checks in a row with no progress.");
198  descriptions.add("ZombieKillerService", desc);
199 }

References edm::ConfigurationDescriptions::add(), and submitPVResolutionJobs::desc.

◆ notAZombieYet()

void ZombieKillerService::notAZombieYet ( )
private

Definition at line 153 of file ZombieKillerService.cc.

153  {
155  m_stillAlive = true;
156 }

References m_numberChecksWhenNotAlive, and m_stillAlive.

Referenced by ZombieKillerService().

◆ startThread()

void ZombieKillerService::startThread ( )
private

Definition at line 172 of file ZombieKillerService.cc.

172  {
173  m_watchingThread = std::thread([this]() {
174  std::unique_lock<std::mutex> lock(m_jobDoneMutex);
175  while (not m_jobDoneCondition.wait_for(
176  lock, std::chrono::seconds(m_secsBetweenChecks), [this]() -> bool { return m_jobDone; })) {
177  //we timed out
178  checkForZombie();
179  }
180  });
181 }

References checkForZombie(), CommonMethods::lock(), m_jobDoneCondition, m_jobDoneMutex, m_secsBetweenChecks, m_watchingThread, and seconds().

Referenced by ZombieKillerService().

◆ stopThread()

void ZombieKillerService::stopThread ( )
private

Definition at line 183 of file ZombieKillerService.cc.

183  {
184  {
185  std::lock_guard<std::mutex> guard(m_jobDoneMutex);
186  m_jobDone = true;
187  }
188  m_jobDoneCondition.notify_all();
189  m_watchingThread.join();
190 }

References m_jobDone, m_jobDoneCondition, m_jobDoneMutex, and m_watchingThread.

Referenced by ZombieKillerService().

Member Data Documentation

◆ m_checkThreshold

const unsigned int edm::ZombieKillerService::m_checkThreshold
private

Definition at line 34 of file ZombieKillerService.cc.

Referenced by checkForZombie().

◆ m_jobDone

bool edm::ZombieKillerService::m_jobDone
private

Definition at line 39 of file ZombieKillerService.cc.

Referenced by stopThread().

◆ m_jobDoneCondition

std::condition_variable edm::ZombieKillerService::m_jobDoneCondition
private

Definition at line 37 of file ZombieKillerService.cc.

Referenced by startThread(), and stopThread().

◆ m_jobDoneMutex

std::mutex edm::ZombieKillerService::m_jobDoneMutex
private

Definition at line 38 of file ZombieKillerService.cc.

Referenced by startThread(), and stopThread().

◆ m_numberChecksWhenNotAlive

std::atomic<unsigned int> edm::ZombieKillerService::m_numberChecksWhenNotAlive
private

Definition at line 41 of file ZombieKillerService.cc.

Referenced by checkForZombie(), and notAZombieYet().

◆ m_secsBetweenChecks

const unsigned int edm::ZombieKillerService::m_secsBetweenChecks
private

Definition at line 35 of file ZombieKillerService.cc.

Referenced by checkForZombie(), and startThread().

◆ m_stillAlive

std::atomic<bool> edm::ZombieKillerService::m_stillAlive
private

Definition at line 40 of file ZombieKillerService.cc.

Referenced by checkForZombie(), and notAZombieYet().

◆ m_watchingThread

std::thread edm::ZombieKillerService::m_watchingThread
private

Definition at line 36 of file ZombieKillerService.cc.

Referenced by startThread(), and stopThread().

edm::ActivityRegistry::watchPreModuleEndStream
void watchPreModuleEndStream(PreModuleEndStream::slot_type const &iSlot)
Definition: ActivityRegistry.h:259
edm::StreamID
Definition: StreamID.h:30
edm::ActivityRegistry::watchPreModuleBeginStream
void watchPreModuleBeginStream(PreModuleBeginStream::slot_type const &iSlot)
Definition: ActivityRegistry.h:245
edm::ActivityRegistry::watchPostModuleGlobalEndRun
void watchPostModuleGlobalEndRun(PostModuleGlobalEndRun::slot_type const &iSlot)
Definition: ActivityRegistry.h:907
edm::ZombieKillerService::m_checkThreshold
const unsigned int m_checkThreshold
Definition: ZombieKillerService.cc:34
edm::ActivityRegistry::watchPostSourceRun
void watchPostSourceRun(PostSourceRun::slot_type const &iSlot)
Definition: ActivityRegistry.h:213
edm::ActivityRegistry::watchPreSourceLumi
void watchPreSourceLumi(PreSourceLumi::slot_type const &iSlot)
Definition: ActivityRegistry.h:195
edm::ZombieKillerService::m_jobDone
bool m_jobDone
Definition: ZombieKillerService.cc:39
edm::ActivityRegistry::watchPostModuleStreamBeginLumi
void watchPostModuleStreamBeginLumi(PostModuleStreamBeginLumi::slot_type const &iSlot)
Definition: ActivityRegistry.h:822
edm::ZombieKillerService::checkForZombie
void checkForZombie()
Definition: ZombieKillerService.cc:158
edm::ActivityRegistry::watchPreModuleEndJob
void watchPreModuleEndJob(PreModuleEndJob::slot_type const &iSlot)
Definition: ActivityRegistry.h:698
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::ZombieKillerService::m_stillAlive
std::atomic< bool > m_stillAlive
Definition: ZombieKillerService.cc:40
edm::ActivityRegistry::watchPostModuleGlobalBeginRun
void watchPostModuleGlobalBeginRun(PostModuleGlobalBeginRun::slot_type const &iSlot)
Definition: ActivityRegistry.h:893
edm::ActivityRegistry::watchPostModuleStreamEndRun
void watchPostModuleStreamEndRun(PostModuleStreamEndRun::slot_type const &iSlot)
Definition: ActivityRegistry.h:808
edm::ActivityRegistry::watchPreModuleStreamBeginRun
void watchPreModuleStreamBeginRun(PreModuleStreamBeginRun::slot_type const &iSlot)
Definition: ActivityRegistry.h:787
edm::ZombieKillerService::startThread
void startThread()
Definition: ZombieKillerService.cc:172
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
edm::ModuleDescription
Definition: ModuleDescription.h:21
edm::ActivityRegistry::watchPostModuleBeginStream
void watchPostModuleBeginStream(PostModuleBeginStream::slot_type const &iSlot)
Definition: ActivityRegistry.h:252
edm::ActivityRegistry::watchPostSourceEvent
void watchPostSourceEvent(PostSourceEvent::slot_type const &iSlot)
Definition: ActivityRegistry.h:189
edm::ActivityRegistry::watchPostModuleEndJob
void watchPostModuleEndJob(PostModuleEndJob::slot_type const &iSlot)
Definition: ActivityRegistry.h:704
edm::ActivityRegistry::watchPreModuleGlobalBeginLumi
void watchPreModuleGlobalBeginLumi(PreModuleGlobalBeginLumi::slot_type const &iSlot)
Definition: ActivityRegistry.h:914
edm::ActivityRegistry::watchPreModuleStreamEndLumi
void watchPreModuleStreamEndLumi(PreModuleStreamEndLumi::slot_type const &iSlot)
Definition: ActivityRegistry.h:829
edm::ActivityRegistry::watchPostEndJob
void watchPostEndJob(PostEndJob::slot_type const &iSlot)
Definition: ActivityRegistry.h:169
edm::LuminosityBlockIndex
Definition: LuminosityBlockIndex.h:33
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
edm::StreamContext
Definition: StreamContext.h:31
edm::ActivityRegistry::watchPostModuleEndStream
void watchPostModuleEndStream(PostModuleEndStream::slot_type const &iSlot)
Definition: ActivityRegistry.h:266
seconds
double seconds()
edm::ZombieKillerService::notAZombieYet
void notAZombieYet()
Definition: ZombieKillerService.cc:153
edm::ActivityRegistry::watchPostBeginJob
void watchPostBeginJob(PostBeginJob::slot_type const &iSlot)
convenience function for attaching to signal
Definition: ActivityRegistry.h:157
edm::ActivityRegistry::watchPreModuleStreamBeginLumi
void watchPreModuleStreamBeginLumi(PreModuleStreamBeginLumi::slot_type const &iSlot)
Definition: ActivityRegistry.h:815
edm::ZombieKillerService::m_jobDoneMutex
std::mutex m_jobDoneMutex
Definition: ZombieKillerService.cc:38
edm::ZombieKillerService::m_secsBetweenChecks
const unsigned int m_secsBetweenChecks
Definition: ZombieKillerService.cc:35
edm::ActivityRegistry::watchPreSourceRun
void watchPreSourceRun(PreSourceRun::slot_type const &iSlot)
Definition: ActivityRegistry.h:207
edm::ActivityRegistry::watchPostSourceLumi
void watchPostSourceLumi(PostSourceLumi::slot_type const &iSlot)
Definition: ActivityRegistry.h:201
edm::ZombieKillerService::m_watchingThread
std::thread m_watchingThread
Definition: ZombieKillerService.cc:36
edm::ActivityRegistry::watchPreModuleGlobalEndLumi
void watchPreModuleGlobalEndLumi(PreModuleGlobalEndLumi::slot_type const &iSlot)
Definition: ActivityRegistry.h:928
edm::GlobalContext
Definition: GlobalContext.h:29
edm::ActivityRegistry::watchPreModuleStreamEndRun
void watchPreModuleStreamEndRun(PreModuleStreamEndRun::slot_type const &iSlot)
Definition: ActivityRegistry.h:801
edm::ActivityRegistry::watchPostModuleGlobalEndLumi
void watchPostModuleGlobalEndLumi(PostModuleGlobalEndLumi::slot_type const &iSlot)
Definition: ActivityRegistry.h:935
CommonMethods.lock
def lock()
Definition: CommonMethods.py:82
edm::ZombieKillerService::m_numberChecksWhenNotAlive
std::atomic< unsigned int > m_numberChecksWhenNotAlive
Definition: ZombieKillerService.cc:41
edm::ActivityRegistry::watchPreModuleGlobalEndRun
void watchPreModuleGlobalEndRun(PreModuleGlobalEndRun::slot_type const &iSlot)
Definition: ActivityRegistry.h:900
edm::ZombieKillerService::stopThread
void stopThread()
Definition: ZombieKillerService.cc:183
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
edm::ActivityRegistry::watchPostModuleStreamEndLumi
void watchPostModuleStreamEndLumi(PostModuleStreamEndLumi::slot_type const &iSlot)
Definition: ActivityRegistry.h:836
edm::ZombieKillerService::m_jobDoneCondition
std::condition_variable m_jobDoneCondition
Definition: ZombieKillerService.cc:37
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
edm::ActivityRegistry::watchPostModuleEvent
void watchPostModuleEvent(PostModuleEvent::slot_type const &iSlot)
Definition: ActivityRegistry.h:734
edm::ActivityRegistry::watchPreModuleGlobalBeginRun
void watchPreModuleGlobalBeginRun(PreModuleGlobalBeginRun::slot_type const &iSlot)
Definition: ActivityRegistry.h:886
edm::ActivityRegistry::watchPreSourceEvent
void watchPreSourceEvent(PreSourceEvent::slot_type const &iSlot)
Definition: ActivityRegistry.h:183
edm::RunIndex
Definition: RunIndex.h:32
edm::ActivityRegistry::watchPostModuleGlobalBeginLumi
void watchPostModuleGlobalBeginLumi(PostModuleGlobalBeginLumi::slot_type const &iSlot)
Definition: ActivityRegistry.h:921
edm::ActivityRegistry::watchPostModuleStreamBeginRun
void watchPostModuleStreamBeginRun(PostModuleStreamBeginRun::slot_type const &iSlot)
Definition: ActivityRegistry.h:794
edm::ActivityRegistry::watchPreModuleEvent
void watchPreModuleEvent(PreModuleEvent::slot_type const &iSlot)
Definition: ActivityRegistry.h:728
edm::ModuleCallingContext
Definition: ModuleCallingContext.h:29