Skip to content

Commit 29e8ec7

Browse files
authored
Merge pull request #48052 from Dr15Jones/signalDelayedGet
Make delayed get signal work with Refs
2 parents e289a14 + 5313b0a commit 29e8ec7

File tree

3 files changed

+36
-22
lines changed

3 files changed

+36
-22
lines changed

FWCore/Framework/src/ProductResolvers.cc

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "FWCore/Framework/interface/DelayedReader.h"
1212
#include "FWCore/Framework/interface/TransitionInfoTypes.h"
1313
#include "FWCore/Framework/interface/ProductProvenanceRetriever.h"
14+
#include "FWCore/ServiceRegistry/interface/CurrentModuleOnThread.h"
1415
#include "DataFormats/Provenance/interface/BranchKey.h"
1516
#include "DataFormats/Provenance/interface/ParentageRegistry.h"
1617
#include "FWCore/MessageLogger/interface/MessageLogger.h"
@@ -176,11 +177,15 @@ namespace edm {
176177
// The file may already be closed so the reader is invalid
177178
return;
178179
}
179-
if (mcc and branchType == InEvent and aux_) {
180-
aux_->preModuleDelayedGetSignal_.emit(*(mcc->getStreamContext()), *mcc);
180+
auto context = mcc;
181+
if (!context) {
182+
context = CurrentModuleOnThread::getCurrentModuleOnThread();
183+
}
184+
if (context and branchType == InEvent and aux_) {
185+
aux_->preModuleDelayedGetSignal_.emit(*(context->getStreamContext()), *context);
181186
}
182187

183-
auto sentry(make_sentry(mcc, [this, branchType](ModuleCallingContext const* iContext) {
188+
auto sentry(make_sentry(context, [this, branchType](ModuleCallingContext const* iContext) {
184189
if (branchType == InEvent and aux_) {
185190
aux_->postModuleDelayedGetSignal_.emit(*(iContext->getStreamContext()), *iContext);
186191
}
@@ -194,13 +199,13 @@ namespace edm {
194199
if (not productResolved()) {
195200
try {
196201
//another thread could have beaten us here
197-
setProduct(reader->getProduct(productDescription().branchID(), &principal, mcc));
202+
setProduct(reader->getProduct(productDescription().branchID(), &principal, context));
198203
} catch (cms::Exception& e) {
199-
extendException(e, productDescription(), mcc);
204+
extendException(e, productDescription(), context);
200205
throw;
201206
} catch (std::exception const& e) {
202207
auto newExcept = edm::Exception(errors::StdException) << e.what();
203-
extendException(newExcept, productDescription(), mcc);
208+
extendException(newExcept, productDescription(), context);
204209
throw newExcept;
205210
}
206211
}

FWCore/Services/plugins/Tracer.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,7 +1448,7 @@ void Tracer::preModuleEventDelayedGet(StreamContext const& sc, ModuleCallingCont
14481448
for (unsigned int i = 0; i < nIndents; ++i) {
14491449
out << indention_;
14501450
}
1451-
out << " starting: delayed processing event for module: stream = " << sc.streamID() << " label = '"
1451+
out << " starting: delayed get while processing event for module: stream = " << sc.streamID() << " label = '"
14521452
<< mcc.moduleDescription()->moduleLabel() << "' id = " << mcc.moduleDescription()->id();
14531453
if (dumpContextForLabels_.find(mcc.moduleDescription()->moduleLabel()) != dumpContextForLabels_.end()) {
14541454
out << "\n" << sc;
@@ -1463,7 +1463,7 @@ void Tracer::postModuleEventDelayedGet(StreamContext const& sc, ModuleCallingCon
14631463
for (unsigned int i = 0; i < nIndents; ++i) {
14641464
out << indention_;
14651465
}
1466-
out << " finished: delayed processing event for module: stream = " << sc.streamID() << " label = '"
1466+
out << " finished: delayed get while processing event for module: stream = " << sc.streamID() << " label = '"
14671467
<< mcc.moduleDescription()->moduleLabel() << "' id = " << mcc.moduleDescription()->id();
14681468
if (dumpContextForLabels_.find(mcc.moduleDescription()->moduleLabel()) != dumpContextForLabels_.end()) {
14691469
out << "\n" << sc;

FWCore/Services/scripts/edmTracerCompactLogViewer.py

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -479,11 +479,11 @@ def textIfTransform(self):
479479
return ''
480480
def text(self, context):
481481
return f'{self.textPrefix(context)} {self.textSpecial()}{self.textIfTransform()}: {self.textPostfix()}'
482-
def _preJson(self, activity, counter, data, mayUseTemp = False):
482+
def _preJson(self, activity, counter, data, mayUseTemp = False, isSrc = False):
483483
index = self.index
484484
found = False
485485
if mayUseTemp:
486-
compare = lambda x: x['type'] == self.transition and x['id'] == self.index and x['mod'] == self.moduleID and x['call'] == self.callID and (x['act'] == Activity.temporary or x['act'] == Activity.externalWork)
486+
compare = lambda x: x['type'] == self.transition and x['id'] == self.index and x['mod'] == self.moduleID and x['call'] == self.callID and ((x.get('isSrc') != None) == isSrc ) and (x['act'] == Activity.temporary or x['act'] == Activity.externalWork)
487487
if transitionIsGlobal(self.transition):
488488
item,slot = data.findLastInModGlobals(index, self.moduleID, compare)
489489
else:
@@ -501,8 +501,8 @@ def _preJson(self, activity, counter, data, mayUseTemp = False):
501501
slot = data.findOpenSlotInModStreams(index, self.moduleID)
502502
slot.append(jsonModuleTransition(type=self.transition, id=self.index, modID=self.moduleID, callID=self.callID, activity=activity, start=self.time))
503503
return slot[-1]
504-
def _postJson(self, counter, data, injectAfter = None):
505-
compare = lambda x: x['id'] == self.index and x['mod'] == self.moduleID and x['call'] == self.callID and x['type'] == self.transition
504+
def _postJson(self, counter, data, injectAfter = None, isSrc = False):
505+
compare = lambda x: x['id'] == self.index and x['mod'] == self.moduleID and x['call'] == self.callID and x['type'] == self.transition and ((x.get('isSrc') != None) == isSrc )
506506
index = self.index
507507
if transitionIsGlobal(self.transition):
508508
item,slot = data.findLastInModGlobals(index, self.moduleID, compare)
@@ -582,28 +582,37 @@ def jsonInfo(self, counter, data):
582582
return self._postJson(counter,data)
583583

584584
class PreEDModuleEventDelayedGetParser(EDModuleTransitionParser):
585-
def __init__(self, payload, names):
585+
def __init__(self, payload, names, moduleCentric):
586586
super().__init__(payload, names)
587+
self._moduleCentric = moduleCentric
587588
def textSpecial(self):
588589
return "starting delayed get"
589590
def jsonInfo(self, counter, data):
590-
return self._preJson(Activity.delayedGet, counter,data)
591+
#a pre delayed get is effectively a post transition as the system assumes one state per module per transition instance
592+
if self._moduleCentric:
593+
#inject a dummy at end of the same slot to guarantee module run is in that slot
594+
return self._postJson(counter, data, jsonModuleTransition(type=self.transition, id=self.index, modID=self.moduleID, callID=self.callID, activity=Activity.temporary, start=self.time))
595+
return self._postJson(counter,data)
596+
#return self._preJson(Activity.delayedGet, counter,data)
591597

592598
class PostEDModuleEventDelayedGetParser(EDModuleTransitionParser):
593-
def __init__(self, payload, names):
599+
def __init__(self, payload, names, moduleCentric):
594600
super().__init__(payload, names)
601+
self._moduleCentric = moduleCentric
595602
def textSpecial(self):
596603
return "finished delayed get"
597604
def jsonInfo(self, counter, data):
598-
return self._postJson(counter,data)
605+
return self._preJson(Activity.process, counter,data, mayUseTemp=self._moduleCentric)
606+
#return self._postJson(counter,data)
599607

600608
class PreEventReadFromSourceParser(EDModuleTransitionParser):
601-
def __init__(self, payload, names):
609+
def __init__(self, payload, names, moduleCentric):
602610
super().__init__(payload, names)
611+
self._moduleCentric = moduleCentric
603612
def textSpecial(self):
604613
return "starting read from source"
605614
def jsonInfo(self, counter, data):
606-
slot = self._preJson(Activity.process, counter,data)
615+
slot = self._preJson(Activity.process, counter,data, mayUseTemp=self._moduleCentric, isSrc=True)
607616
slot['isSrc'] = True
608617
return slot
609618

@@ -613,7 +622,7 @@ def __init__(self, payload, names):
613622
def textSpecial(self):
614623
return "finished read from source"
615624
def jsonInfo(self, counter, data):
616-
return self._postJson(counter,data)
625+
return self._postJson(counter,data, isSrc=True)
617626

618627
class ESModuleTransitionParser(object):
619628
def __init__(self, payload, moduleNames, esModuleNames, recordNames):
@@ -747,11 +756,11 @@ def lineParserFactory (step, payload, moduleNames, esModuleNames, recordNames, f
747756
if step == 'a':
748757
return PostEDModuleAcquireParser(payload, moduleNames, moduleCentric)
749758
if step == 'D':
750-
return PreEDModuleEventDelayedGetParser(payload, moduleNames)
759+
return PreEDModuleEventDelayedGetParser(payload, moduleNames, moduleCentric)
751760
if step == 'd':
752-
return PostEDModuleEventDelayedGetParser(payload, moduleNames)
761+
return PostEDModuleEventDelayedGetParser(payload, moduleNames, moduleCentric)
753762
if step == 'R':
754-
return PreEventReadFromSourceParser(payload, moduleNames)
763+
return PreEventReadFromSourceParser(payload, moduleNames, moduleCentric)
755764
if step == 'r':
756765
return PostEventReadFromSourceParser(payload, moduleNames)
757766
if step == 'N':

0 commit comments

Comments
 (0)