Skip to content

Commit

Permalink
Merge pull request #37771 from Dr15Jones/iovTransitions
Browse files Browse the repository at this point in the history
Added IOV synchronization callbacks to ActivityRegistry
  • Loading branch information
cmsbuild committed May 3, 2022
2 parents 6091391 + d610b60 commit ef3080b
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 1 deletion.
9 changes: 8 additions & 1 deletion FWCore/Framework/src/EventProcessor.cc
Expand Up @@ -1146,7 +1146,9 @@ namespace edm {
}
{
SendSourceTerminationSignalIfException sentry(actReg_.get());
actReg_->preESSyncIOVSignal_.emit(ts);
synchronousEventSetupForInstance(ts, taskGroup_, *espController_);
actReg_->postESSyncIOVSignal_.emit(ts);
eventSetupForInstanceSucceeded = true;
sentry.completedSuccessfully();
}
Expand Down Expand Up @@ -1261,7 +1263,9 @@ namespace edm {
runPrincipal.endTime());
{
SendSourceTerminationSignalIfException sentry(actReg_.get());
actReg_->preESSyncIOVSignal_.emit(ts);
synchronousEventSetupForInstance(ts, taskGroup_, *espController_);
actReg_->postESSyncIOVSignal_.emit(ts);
sentry.completedSuccessfully();
}
auto const& es = esp_->eventSetupImpl();
Expand Down Expand Up @@ -1344,6 +1348,7 @@ namespace edm {
return;
}

actReg_->esSyncIOVQueuingSignal_.emit(iSync);
// We must be careful with the status object here and in code this function calls. IF we want
// endRun to be called, then we must call resetResources before the things waiting on
// iHolder are allowed to proceed. Otherwise, there will be race condition (possibly causing
Expand All @@ -1368,6 +1373,7 @@ namespace edm {
// need to be processed and prepare IOVs for it.
// Pass in the endIOVWaitingTasks so the lumi can notify them when the
// lumi is done and no longer needs its EventSetup IOVs.
actReg->preESSyncIOVSignal_.emit(iSync);
espController->eventSetupForInstanceAsync(
iSync, task, status->endIOVWaitingTasks(), status->eventSetupImpls());
sentry.completedSuccessfully();
Expand All @@ -1389,7 +1395,8 @@ namespace edm {
asyncEventSetup(
actReg_.get(), espController_.get(), queueWhichWaitsForIOVsToFinish_, std::move(nextTask), status, iSync);
}
}) | chain::then([this, status](std::exception_ptr const* iPtr, auto nextTask) {
}) | chain::then([this, status, iSync](std::exception_ptr const* iPtr, auto nextTask) {
actReg_->postESSyncIOVSignal_.emit(iSync);
//the call to doneWaiting will cause the count to decrement
auto copyTask = nextTask;
if (iPtr) {
Expand Down
Expand Up @@ -75,6 +75,8 @@ ModuleCallingContext state = Running
++++ finished: begin process block
++++ starting: source run
++++ finished: source run
++++ pre: EventSetup synchronizing run: 1 lumi: 0 event: 0
++++ post: EventSetup synchronizing run: 1 lumi: 0 event: 0
++++ starting: global begin run 1 : time = 1000000
++++ finished: global begin run 1 : time = 1000000
++++ starting: begin run: stream = 0 run = 1 time = 1000000
Expand Down Expand Up @@ -103,6 +105,9 @@ ModuleCallingContext state = Running
ProcessContext: TEST d84cfc6bef4d9d1fe04243c166360a06

++++ finished: begin run: stream = 0 run = 1 time = 1000000
++++ queuing: EventSetup synchronization run: 1 lumi: 1 event: 0
++++ pre: EventSetup synchronizing run: 1 lumi: 1 event: 0
++++ post: EventSetup synchronizing run: 1 lumi: 1 event: 0
++++ starting: source lumi
++++ finished: source lumi
++++ starting: global begin lumi: run = 1 lumi = 1 time = 1000000
Expand Down Expand Up @@ -505,6 +510,8 @@ ModuleCallingContext state = Running
++++ finished: global end lumi: run = 1 lumi = 1 time = 1000000
++++ starting: global write lumi: run = 1 lumi = 1 time = 1000000
++++ finished: global write lumi: run = 1 lumi = 1 time = 1000000
++++ pre: EventSetup synchronizing run: 1 lumi: 4294967295 event: 18446744073709551615
++++ post: EventSetup synchronizing run: 1 lumi: 4294967295 event: 18446744073709551615
++++ starting: end run: stream = 0 run = 1 time = 1000030
++++++ starting: end run for module: stream = 0 label = 'one' id = 4
StreamContext: StreamID = 0 transition = EndRun
Expand Down
Expand Up @@ -43,6 +43,8 @@
++++ finished: begin process block
++++ starting: source run
++++ finished: source run
++++ pre: EventSetup synchronizing run: 1 lumi: 0 event: 0
++++ post: EventSetup synchronizing run: 1 lumi: 0 event: 0
++++ starting: global begin run 1 : time = 1000000
++++ finished: global begin run 1 : time = 1000000
++++ starting: begin run: stream = 0 run = 1 time = 1000000
Expand All @@ -51,6 +53,9 @@
++++++ starting: begin run for module: stream = 0 label = 'one' id = 3
++++++ finished: begin run for module: stream = 0 label = 'one' id = 3
++++ finished: begin run: stream = 0 run = 1 time = 1000000
++++ queuing: EventSetup synchronization run: 1 lumi: 1 event: 0
++++ pre: EventSetup synchronizing run: 1 lumi: 1 event: 0
++++ post: EventSetup synchronizing run: 1 lumi: 1 event: 0
++++ starting: source lumi
++++ finished: source lumi
++++ starting: global begin lumi: run = 1 lumi = 1 time = 1000000
Expand Down Expand Up @@ -149,6 +154,8 @@
++++ finished: global end lumi: run = 1 lumi = 1 time = 1000000
++++ starting: global write lumi: run = 1 lumi = 1 time = 1000000
++++ finished: global write lumi: run = 1 lumi = 1 time = 1000000
++++ pre: EventSetup synchronizing run: 1 lumi: 4294967295 event: 18446744073709551615
++++ post: EventSetup synchronizing run: 1 lumi: 4294967295 event: 18446744073709551615
++++ starting: end run: stream = 0 run = 1 time = 1000030
++++++ starting: end run for module: stream = 0 label = 'two' id = 5
++++++ finished: end run for module: stream = 0 label = 'two' id = 5
Expand Down
7 changes: 7 additions & 0 deletions FWCore/Integration/test/unit_test_outputs/testGetBy1.log
Expand Up @@ -202,6 +202,8 @@ GlobalContext: transition = BeginProcessBlock

++++ starting: source run
++++ finished: source run
++++ pre: EventSetup synchronizing run: 1 lumi: 0 event: 0
++++ post: EventSetup synchronizing run: 1 lumi: 0 event: 0
++++ starting: global begin run 1 : time = 1
GlobalContext: transition = BeginRun
run: 1 luminosityBlock: 0
Expand Down Expand Up @@ -312,6 +314,9 @@ StreamContext: StreamID = 0 transition = BeginRun
ProcessContext: COPY 5ea2a17b2b2eaa97af73c630882cd994
parent ProcessContext: PROD1 be16549dc0c1f4b03231a8b98d235dac

++++ queuing: EventSetup synchronization run: 1 lumi: 1 event: 0
++++ pre: EventSetup synchronizing run: 1 lumi: 1 event: 0
++++ post: EventSetup synchronizing run: 1 lumi: 1 event: 0
++++ starting: source lumi
++++ finished: source lumi
++++ starting: global begin lumi: run = 1 lumi = 1 time = 1
Expand Down Expand Up @@ -1240,6 +1245,8 @@ GlobalContext: transition = WriteLuminosityBlock
ProcessContext: COPY 5ea2a17b2b2eaa97af73c630882cd994
parent ProcessContext: PROD1 be16549dc0c1f4b03231a8b98d235dac

++++ pre: EventSetup synchronizing run: 1 lumi: 4294967295 event: 18446744073709551615
++++ post: EventSetup synchronizing run: 1 lumi: 4294967295 event: 18446744073709551615
++++ starting: end run: stream = 0 run = 1 time = 15000001
StreamContext: StreamID = 0 transition = EndRun
run: 1 lumi: 0 event: 0
Expand Down
7 changes: 7 additions & 0 deletions FWCore/Integration/test/unit_test_outputs/testGetBy2.log
Expand Up @@ -117,6 +117,8 @@ GlobalContext: transition = WriteProcessBlock

++++ starting: source run
++++ finished: source run
++++ pre: EventSetup synchronizing run: 1 lumi: 0 event: 0
++++ post: EventSetup synchronizing run: 1 lumi: 0 event: 0
++++ starting: global begin run 1 : time = 1
GlobalContext: transition = BeginRun
run: 1 luminosityBlock: 0
Expand Down Expand Up @@ -167,6 +169,9 @@ StreamContext: StreamID = 0 transition = BeginRun
runIndex = 0 luminosityBlockIndex = 4294967295 unixTime = 0 microsecondOffset = 1
ProcessContext: PROD2 7da3661f4f7dead5e42f07cf3ddf5a59

++++ queuing: EventSetup synchronization run: 1 lumi: 1 event: 0
++++ pre: EventSetup synchronizing run: 1 lumi: 1 event: 0
++++ post: EventSetup synchronizing run: 1 lumi: 1 event: 0
++++ starting: source lumi
++++ finished: source lumi
++++ starting: global begin lumi: run = 1 lumi = 1 time = 1
Expand Down Expand Up @@ -727,6 +732,8 @@ GlobalContext: transition = WriteLuminosityBlock
runIndex = 0 luminosityBlockIndex = 0 unixTime = 0 microsecondOffset = 1
ProcessContext: PROD2 7da3661f4f7dead5e42f07cf3ddf5a59

++++ pre: EventSetup synchronizing run: 1 lumi: 4294967295 event: 18446744073709551615
++++ post: EventSetup synchronizing run: 1 lumi: 4294967295 event: 18446744073709551615
++++ starting: end run: stream = 0 run = 1 time = 15000001
StreamContext: StreamID = 0 transition = EndRun
run: 1 lumi: 0 event: 0
Expand Down
39 changes: 39 additions & 0 deletions FWCore/Integration/test/unit_test_outputs/testSubProcess.grep2.txt
Expand Up @@ -250,6 +250,8 @@
++++ finished: begin process block
++++ starting: source run
++++ finished: source run
++++ pre: EventSetup synchronizing run: 1 lumi: 0 event: 0
++++ post: EventSetup synchronizing run: 1 lumi: 0 event: 0
++++ starting: global begin run 1 : time = 1
++++ finished: global begin run 1 : time = 1
++++ starting: global begin run 1 : time = 1
Expand Down Expand Up @@ -320,6 +322,9 @@
++++ finished: begin run: stream = 0 run = 1 time = 1
++++ starting: begin run: stream = 0 run = 1 time = 1
++++ finished: begin run: stream = 0 run = 1 time = 1
++++ queuing: EventSetup synchronization run: 1 lumi: 1 event: 0
++++ pre: EventSetup synchronizing run: 1 lumi: 1 event: 0
++++ post: EventSetup synchronizing run: 1 lumi: 1 event: 0
++++ starting: source lumi
++++ finished: source lumi
++++ starting: global begin lumi: run = 1 lumi = 1 time = 1
Expand Down Expand Up @@ -1008,6 +1013,8 @@
++++++++ finished: processing event for module: stream = 0 label = 'endPath1' id = 30
++++++ finished: processing path 'endPath1' : stream = 0
++++ finished: processing event : stream = 0 run = 1 lumi = 1 event = 4 time = 20000001
++++ queuing: EventSetup synchronization run: 1 lumi: 2 event: 0
++++ pre: EventSetup synchronizing run: 1 lumi: 2 event: 0
++++ starting: end lumi: stream = 0 run = 1 lumi = 1 time = 20000001
++++ finished: end lumi: stream = 0 run = 1 lumi = 1 time = 20000001
++++ starting: end lumi: stream = 0 run = 1 lumi = 1 time = 0
Expand Down Expand Up @@ -1086,6 +1093,7 @@
++++++ starting: write lumi for module: label = 'out' id = 24
++++++ finished: write lumi for module: label = 'out' id = 24
++++ finished: global write lumi: run = 1 lumi = 1 time = 1
++++ post: EventSetup synchronizing run: 1 lumi: 2 event: 0
++++ starting: source lumi
++++ finished: source lumi
++++ starting: global begin lumi: run = 1 lumi = 2 time = 25000001
Expand Down Expand Up @@ -1774,6 +1782,8 @@
++++++++ finished: processing event for module: stream = 0 label = 'endPath1' id = 30
++++++ finished: processing path 'endPath1' : stream = 0
++++ finished: processing event : stream = 0 run = 1 lumi = 2 event = 8 time = 40000001
++++ queuing: EventSetup synchronization run: 1 lumi: 3 event: 0
++++ pre: EventSetup synchronizing run: 1 lumi: 3 event: 0
++++ starting: end lumi: stream = 0 run = 1 lumi = 2 time = 40000001
++++ finished: end lumi: stream = 0 run = 1 lumi = 2 time = 40000001
++++ starting: end lumi: stream = 0 run = 1 lumi = 2 time = 0
Expand Down Expand Up @@ -1852,6 +1862,7 @@
++++++ starting: write lumi for module: label = 'out' id = 24
++++++ finished: write lumi for module: label = 'out' id = 24
++++ finished: global write lumi: run = 1 lumi = 2 time = 25000001
++++ post: EventSetup synchronizing run: 1 lumi: 3 event: 0
++++ starting: source lumi
++++ finished: source lumi
++++ starting: global begin lumi: run = 1 lumi = 3 time = 45000001
Expand Down Expand Up @@ -2306,6 +2317,8 @@
++++++ starting: write lumi for module: label = 'out' id = 24
++++++ finished: write lumi for module: label = 'out' id = 24
++++ finished: global write lumi: run = 1 lumi = 3 time = 45000001
++++ pre: EventSetup synchronizing run: 1 lumi: 4294967295 event: 18446744073709551615
++++ post: EventSetup synchronizing run: 1 lumi: 4294967295 event: 18446744073709551615
++++ starting: end run: stream = 0 run = 1 time = 50000001
++++ finished: end run: stream = 0 run = 1 time = 50000001
++++ starting: end run: stream = 0 run = 1 time = 0
Expand Down Expand Up @@ -2386,6 +2399,8 @@
++++ finished: global write run 1 : time = 0
++++ starting: source run
++++ finished: source run
++++ pre: EventSetup synchronizing run: 2 lumi: 0 event: 0
++++ post: EventSetup synchronizing run: 2 lumi: 0 event: 0
++++ starting: global begin run 2 : time = 55000001
++++ finished: global begin run 2 : time = 55000001
++++ starting: global begin run 2 : time = 55000001
Expand Down Expand Up @@ -2448,6 +2463,9 @@
++++ finished: begin run: stream = 0 run = 2 time = 55000001
++++ starting: begin run: stream = 0 run = 2 time = 55000001
++++ finished: begin run: stream = 0 run = 2 time = 55000001
++++ queuing: EventSetup synchronization run: 2 lumi: 1 event: 0
++++ pre: EventSetup synchronizing run: 2 lumi: 1 event: 0
++++ post: EventSetup synchronizing run: 2 lumi: 1 event: 0
++++ starting: source lumi
++++ finished: source lumi
++++ starting: global begin lumi: run = 2 lumi = 1 time = 55000001
Expand Down Expand Up @@ -3136,6 +3154,8 @@
++++++++ finished: processing event for module: stream = 0 label = 'endPath1' id = 30
++++++ finished: processing path 'endPath1' : stream = 0
++++ finished: processing event : stream = 0 run = 2 lumi = 1 event = 4 time = 70000001
++++ queuing: EventSetup synchronization run: 2 lumi: 2 event: 0
++++ pre: EventSetup synchronizing run: 2 lumi: 2 event: 0
++++ starting: end lumi: stream = 0 run = 2 lumi = 1 time = 70000001
++++ finished: end lumi: stream = 0 run = 2 lumi = 1 time = 70000001
++++ starting: end lumi: stream = 0 run = 2 lumi = 1 time = 0
Expand Down Expand Up @@ -3214,6 +3234,7 @@
++++++ starting: write lumi for module: label = 'out' id = 24
++++++ finished: write lumi for module: label = 'out' id = 24
++++ finished: global write lumi: run = 2 lumi = 1 time = 55000001
++++ post: EventSetup synchronizing run: 2 lumi: 2 event: 0
++++ starting: source lumi
++++ finished: source lumi
++++ starting: global begin lumi: run = 2 lumi = 2 time = 75000001
Expand Down Expand Up @@ -3902,6 +3923,8 @@
++++++++ finished: processing event for module: stream = 0 label = 'endPath1' id = 30
++++++ finished: processing path 'endPath1' : stream = 0
++++ finished: processing event : stream = 0 run = 2 lumi = 2 event = 8 time = 90000001
++++ queuing: EventSetup synchronization run: 2 lumi: 3 event: 0
++++ pre: EventSetup synchronizing run: 2 lumi: 3 event: 0
++++ starting: end lumi: stream = 0 run = 2 lumi = 2 time = 90000001
++++ finished: end lumi: stream = 0 run = 2 lumi = 2 time = 90000001
++++ starting: end lumi: stream = 0 run = 2 lumi = 2 time = 0
Expand Down Expand Up @@ -3980,6 +4003,7 @@
++++++ starting: write lumi for module: label = 'out' id = 24
++++++ finished: write lumi for module: label = 'out' id = 24
++++ finished: global write lumi: run = 2 lumi = 2 time = 75000001
++++ post: EventSetup synchronizing run: 2 lumi: 3 event: 0
++++ starting: source lumi
++++ finished: source lumi
++++ starting: global begin lumi: run = 2 lumi = 3 time = 95000001
Expand Down Expand Up @@ -4434,6 +4458,8 @@
++++++ starting: write lumi for module: label = 'out' id = 24
++++++ finished: write lumi for module: label = 'out' id = 24
++++ finished: global write lumi: run = 2 lumi = 3 time = 95000001
++++ pre: EventSetup synchronizing run: 2 lumi: 4294967295 event: 18446744073709551615
++++ post: EventSetup synchronizing run: 2 lumi: 4294967295 event: 18446744073709551615
++++ starting: end run: stream = 0 run = 2 time = 100000001
++++ finished: end run: stream = 0 run = 2 time = 100000001
++++ starting: end run: stream = 0 run = 2 time = 0
Expand Down Expand Up @@ -4514,6 +4540,8 @@
++++ finished: global write run 2 : time = 0
++++ starting: source run
++++ finished: source run
++++ pre: EventSetup synchronizing run: 3 lumi: 0 event: 0
++++ post: EventSetup synchronizing run: 3 lumi: 0 event: 0
++++ starting: global begin run 3 : time = 105000001
++++ finished: global begin run 3 : time = 105000001
++++ starting: global begin run 3 : time = 105000001
Expand Down Expand Up @@ -4576,6 +4604,9 @@
++++ finished: begin run: stream = 0 run = 3 time = 105000001
++++ starting: begin run: stream = 0 run = 3 time = 105000001
++++ finished: begin run: stream = 0 run = 3 time = 105000001
++++ queuing: EventSetup synchronization run: 3 lumi: 1 event: 0
++++ pre: EventSetup synchronizing run: 3 lumi: 1 event: 0
++++ post: EventSetup synchronizing run: 3 lumi: 1 event: 0
++++ starting: source lumi
++++ finished: source lumi
++++ starting: global begin lumi: run = 3 lumi = 1 time = 105000001
Expand Down Expand Up @@ -5264,6 +5295,7 @@
++++++++ finished: processing event for module: stream = 0 label = 'endPath1' id = 30
++++++ finished: processing path 'endPath1' : stream = 0
++++ finished: processing event : stream = 0 run = 3 lumi = 1 event = 4 time = 120000001
++++ queuing: EventSetup synchronization run: 3 lumi: 2 event: 0
++++ starting: end lumi: stream = 0 run = 3 lumi = 1 time = 120000001
++++ finished: end lumi: stream = 0 run = 3 lumi = 1 time = 120000001
++++ starting: end lumi: stream = 0 run = 3 lumi = 1 time = 0
Expand Down Expand Up @@ -5342,6 +5374,8 @@
++++++ starting: write lumi for module: label = 'out' id = 24
++++++ finished: write lumi for module: label = 'out' id = 24
++++ finished: global write lumi: run = 3 lumi = 1 time = 105000001
++++ pre: EventSetup synchronizing run: 3 lumi: 2 event: 0
++++ post: EventSetup synchronizing run: 3 lumi: 2 event: 0
++++ starting: source lumi
++++ finished: source lumi
++++ starting: global begin lumi: run = 3 lumi = 2 time = 125000001
Expand Down Expand Up @@ -6030,6 +6064,7 @@
++++++++ finished: processing event for module: stream = 0 label = 'endPath1' id = 30
++++++ finished: processing path 'endPath1' : stream = 0
++++ finished: processing event : stream = 0 run = 3 lumi = 2 event = 8 time = 140000001
++++ queuing: EventSetup synchronization run: 3 lumi: 3 event: 0
++++ starting: end lumi: stream = 0 run = 3 lumi = 2 time = 140000001
++++ finished: end lumi: stream = 0 run = 3 lumi = 2 time = 140000001
++++ starting: end lumi: stream = 0 run = 3 lumi = 2 time = 0
Expand Down Expand Up @@ -6108,6 +6143,8 @@
++++++ starting: write lumi for module: label = 'out' id = 24
++++++ finished: write lumi for module: label = 'out' id = 24
++++ finished: global write lumi: run = 3 lumi = 2 time = 125000001
++++ pre: EventSetup synchronizing run: 3 lumi: 3 event: 0
++++ post: EventSetup synchronizing run: 3 lumi: 3 event: 0
++++ starting: source lumi
++++ finished: source lumi
++++ starting: global begin lumi: run = 3 lumi = 3 time = 145000001
Expand Down Expand Up @@ -6562,6 +6599,8 @@
++++++ starting: write lumi for module: label = 'out' id = 24
++++++ finished: write lumi for module: label = 'out' id = 24
++++ finished: global write lumi: run = 3 lumi = 3 time = 145000001
++++ pre: EventSetup synchronizing run: 3 lumi: 4294967295 event: 18446744073709551615
++++ post: EventSetup synchronizing run: 3 lumi: 4294967295 event: 18446744073709551615
++++ starting: end run: stream = 0 run = 3 time = 150000001
++++ finished: end run: stream = 0 run = 3 time = 150000001
++++ starting: end run: stream = 0 run = 3 time = 0
Expand Down
19 changes: 19 additions & 0 deletions FWCore/ServiceRegistry/interface/ActivityRegistry.h
Expand Up @@ -93,6 +93,7 @@ namespace edm {
class LuminosityBlock;
class Run;
class EventSetup;
class IOVSyncValue;
class HLTPathStatus;
class GlobalContext;
class StreamContext;
Expand Down Expand Up @@ -526,6 +527,24 @@ namespace edm {
}
AR_WATCH_USING_METHOD_1(watchPostESModuleRegistration)

/// signal is emitted when a new IOV may be needed so we queue a task to do that
using ESSyncIOVQueuing = signalslot::Signal<void(IOVSyncValue const&)>;
ESSyncIOVQueuing esSyncIOVQueuingSignal_;
void watchESSyncIOVQueuing(ESSyncIOVQueuing::slot_type const& iSlot) { esSyncIOVQueuingSignal_.connect(iSlot); }
AR_WATCH_USING_METHOD_1(watchESSyncIOVQueuing)

/// signal is emitted just before a new IOV is synchronized
using PreESSyncIOV = signalslot::Signal<void(IOVSyncValue const&)>;
PreESSyncIOV preESSyncIOVSignal_;
void watchPreESSyncIOV(PreESSyncIOV::slot_type const& iSlot) { preESSyncIOVSignal_.connect(iSlot); }
AR_WATCH_USING_METHOD_1(watchPreESSyncIOV)

/// signal is emitted just after a new IOV is synchronized
using PostESSyncIOV = signalslot::Signal<void(IOVSyncValue const&)>;
PostESSyncIOV postESSyncIOVSignal_;
void watchPostESSyncIOV(PostESSyncIOV::slot_type const& iSlot) { postESSyncIOVSignal_.connect(iSlot); }
AR_WATCH_USING_METHOD_1(watchPostESSyncIOV)

/// signal is emitted before the esmodule starts processing and before prefetching has started
typedef signalslot::Signal<void(eventsetup::EventSetupRecordKey const&, ESModuleCallingContext const&)>
PreESModulePrefetching;
Expand Down

0 comments on commit ef3080b

Please sign in to comment.