diff --git a/FWCore/Framework/interface/DataProxy.h b/FWCore/Framework/interface/DataProxy.h index 554799b655451..e845b3e3273fc 100644 --- a/FWCore/Framework/interface/DataProxy.h +++ b/FWCore/Framework/interface/DataProxy.h @@ -27,6 +27,8 @@ // forward declarations namespace edm { + class ActivityRegistry; + namespace eventsetup { struct ComponentDescription; class DataKey; @@ -41,8 +43,8 @@ namespace edm { // ---------- const member functions --------------------- bool cacheIsValid() const { return cacheIsValid_.load(std::memory_order_acquire); } - void doGet(EventSetupRecord const& iRecord, DataKey const& iKey, bool iTransiently) const; - void const* get(EventSetupRecord const&, DataKey const& iKey, bool iTransiently) const; + void doGet(EventSetupRecord const& iRecord, DataKey const& iKey, bool iTransiently, ActivityRegistry*) const; + void const* get(EventSetupRecord const&, DataKey const& iKey, bool iTransiently, ActivityRegistry*) const; ///returns the description of the DataProxyProvider which owns this Proxy ComponentDescription const* providerDescription() const { diff --git a/FWCore/Framework/interface/EventSetup.h b/FWCore/Framework/interface/EventSetup.h index b075019b7355c..8704c68479f07 100644 --- a/FWCore/Framework/interface/EventSetup.h +++ b/FWCore/Framework/interface/EventSetup.h @@ -35,6 +35,7 @@ // forward declarations namespace edm { + class ActivityRegistry; class ESInputTag; namespace eventsetup { @@ -116,6 +117,9 @@ namespace edm { getAvoidCompilerBug(const T*& iValue) const { iValue = &(get()); } + + friend class eventsetup::EventSetupRecord; + protected: //Only called by EventSetupProvider void setKnownRecordsSupplier(eventsetup::EventSetupKnownRecordsSupplier const* iSupplier) { @@ -127,12 +131,14 @@ namespace edm { void clear(); private: - EventSetup(); + EventSetup(ActivityRegistry*); EventSetup(EventSetup const&) = delete; // stop default EventSetup const& operator=(EventSetup const&) = delete; // stop default + ActivityRegistry* activityRegistry() const { return activityRegistry_; } + void insert(const eventsetup::EventSetupRecordKey&, const eventsetup::EventSetupRecord*); @@ -141,6 +147,7 @@ namespace edm { //NOTE: the records are not owned std::map recordMap_; eventsetup::EventSetupKnownRecordsSupplier const* knownRecords_; + ActivityRegistry* activityRegistry_; }; // Free functions to retrieve an object from the EventSetup. diff --git a/FWCore/Framework/interface/EventSetupProvider.h b/FWCore/Framework/interface/EventSetupProvider.h index 5dd7a83843508..b3dfa911a595d 100644 --- a/FWCore/Framework/interface/EventSetupProvider.h +++ b/FWCore/Framework/interface/EventSetupProvider.h @@ -33,6 +33,7 @@ // forward declarations namespace edm { + class ActivityRegistry; class EventSetupRecordIntervalFinder; class IOVSyncValue; class ParameterSet; @@ -57,7 +58,7 @@ class EventSetupProvider { typedef std::multimap RecordToDataMap; typedef std::map PreferredProviderInfo; - EventSetupProvider(unsigned subProcessIndex = 0U, PreferredProviderInfo const* iInfo = nullptr); + EventSetupProvider(ActivityRegistry*, unsigned subProcessIndex = 0U, PreferredProviderInfo const* iInfo = nullptr); virtual ~EventSetupProvider(); // ---------- const member functions --------------------- diff --git a/FWCore/Framework/interface/EventSetupProviderMaker.h b/FWCore/Framework/interface/EventSetupProviderMaker.h index d5a8c824bda2d..602f89a34beaa 100644 --- a/FWCore/Framework/interface/EventSetupProviderMaker.h +++ b/FWCore/Framework/interface/EventSetupProviderMaker.h @@ -6,13 +6,14 @@ // forward declarations namespace edm { + class ActivityRegistry; class ParameterSet; namespace eventsetup { class EventSetupProvider; class EventSetupsController; std::unique_ptr - makeEventSetupProvider(ParameterSet const& params, unsigned subProcessIndex); + makeEventSetupProvider(ParameterSet const& params, unsigned subProcessIndex, ActivityRegistry*); void fillEventSetupProvider(EventSetupsController& esController, diff --git a/FWCore/Framework/src/DataProxy.cc b/FWCore/Framework/src/DataProxy.cc index 7158ea6fa384f..58f2aa4c122ab 100644 --- a/FWCore/Framework/src/DataProxy.cc +++ b/FWCore/Framework/src/DataProxy.cc @@ -18,7 +18,7 @@ #include "FWCore/Framework/interface/ComponentDescription.h" #include "FWCore/Framework/interface/MakeDataException.h" #include "FWCore/Framework/interface/EventSetupRecord.h" - +#include "FWCore/ServiceRegistry/interface/ActivityRegistry.h" // // constants, enums and typedefs @@ -97,14 +97,47 @@ namespace { const DataKey& iKey) { throw MakeDataException(iRecord.key(),iKey); } + + class ESSignalSentry { + public: + ESSignalSentry(const EventSetupRecord& iRecord, + const DataKey& iKey, + ComponentDescription const* componentDescription, + ActivityRegistry* activityRegistry) : + eventSetupRecord_(iRecord), + dataKey_(iKey), + componentDescription_(componentDescription), + calledPostLock_(false), + activityRegistry_(activityRegistry) { + + activityRegistry->preLockEventSetupGetSignal_(componentDescription_, eventSetupRecord_.key(), dataKey_); + } + void sendPostLockSignal() { + calledPostLock_ = true; + activityRegistry_->postLockEventSetupGetSignal_(componentDescription_, eventSetupRecord_.key(), dataKey_); + } + ~ESSignalSentry() noexcept(false) { + if (!calledPostLock_) { + activityRegistry_->postLockEventSetupGetSignal_(componentDescription_, eventSetupRecord_.key(), dataKey_); + } + activityRegistry_->postEventSetupGetSignal_(componentDescription_, eventSetupRecord_.key(), dataKey_); + } + private: + EventSetupRecord const& eventSetupRecord_; + DataKey const& dataKey_; + ComponentDescription const* componentDescription_; + bool calledPostLock_; + ActivityRegistry* activityRegistry_; + }; } - - + const void* -DataProxy::get(const EventSetupRecord& iRecord, const DataKey& iKey, bool iTransiently) const +DataProxy::get(const EventSetupRecord& iRecord, const DataKey& iKey, bool iTransiently, ActivityRegistry* activityRegistry) const { if(!cacheIsValid()) { + ESSignalSentry signalSentry(iRecord, iKey, providerDescription(), activityRegistry); std::lock_guard guard(s_esGlobalMutex); + signalSentry.sendPostLockSignal(); if(!cacheIsValid()) { cache_ = const_cast(this)->getImpl(iRecord, iKey); cacheIsValid_.store(true,std::memory_order_release); @@ -123,8 +156,8 @@ DataProxy::get(const EventSetupRecord& iRecord, const DataKey& iKey, bool iTrans return cache_; } -void DataProxy::doGet(const EventSetupRecord& iRecord, const DataKey& iKey, bool iTransiently) const { - get(iRecord, iKey, iTransiently); +void DataProxy::doGet(const EventSetupRecord& iRecord, const DataKey& iKey, bool iTransiently, ActivityRegistry* activityRegistry) const { + get(iRecord, iKey, iTransiently, activityRegistry); } diff --git a/FWCore/Framework/src/EventProcessor.cc b/FWCore/Framework/src/EventProcessor.cc index 4315084f33aba..11f6230639270 100644 --- a/FWCore/Framework/src/EventProcessor.cc +++ b/FWCore/Framework/src/EventProcessor.cc @@ -475,7 +475,7 @@ namespace edm { std::shared_ptr common(items.initMisc(*parameterSet)); // intialize the event setup provider - esp_ = espController_->makeProvider(*parameterSet); + esp_ = espController_->makeProvider(*parameterSet, items.actReg_.get()); // initialize the looper, if any looper_ = fillLooper(*espController_, *esp_, *parameterSet); diff --git a/FWCore/Framework/src/EventSetup.cc b/FWCore/Framework/src/EventSetup.cc index abedd7aa2d2fe..22d1ac59f7a4e 100644 --- a/FWCore/Framework/src/EventSetup.cc +++ b/FWCore/Framework/src/EventSetup.cc @@ -31,7 +31,10 @@ namespace edm { // // constructors and destructor // - EventSetup::EventSetup() : recordMap_() +EventSetup::EventSetup(ActivityRegistry* activityRegistry) : + recordMap_(), + activityRegistry_(activityRegistry) + { } diff --git a/FWCore/Framework/src/EventSetupProvider.cc b/FWCore/Framework/src/EventSetupProvider.cc index 39cc4c93c4e8d..101fc2d4fddb1 100644 --- a/FWCore/Framework/src/EventSetupProvider.cc +++ b/FWCore/Framework/src/EventSetupProvider.cc @@ -61,8 +61,10 @@ namespace edm { // // constructors and destructor // -EventSetupProvider::EventSetupProvider(unsigned subProcessIndex, const PreferredProviderInfo* iInfo) : -eventSetup_(), +EventSetupProvider::EventSetupProvider(ActivityRegistry* activityRegistry, + unsigned subProcessIndex, + const PreferredProviderInfo* iInfo) : +eventSetup_(activityRegistry), providers_(), knownRecordsSupplier_( std::make_unique(providers_)), mustFinishConfiguration_(true), diff --git a/FWCore/Framework/src/EventSetupProviderMaker.cc b/FWCore/Framework/src/EventSetupProviderMaker.cc index 2ee01ed45588b..9e48c2e5cf141 100644 --- a/FWCore/Framework/src/EventSetupProviderMaker.cc +++ b/FWCore/Framework/src/EventSetupProviderMaker.cc @@ -23,12 +23,12 @@ namespace edm { namespace eventsetup { // --------------------------------------------------------------- std::unique_ptr - makeEventSetupProvider(ParameterSet const& params, unsigned subProcessIndex) { + makeEventSetupProvider(ParameterSet const& params, unsigned subProcessIndex, ActivityRegistry* activityRegistry) { std::vector prefers = params.getParameter >("@all_esprefers"); if(prefers.empty()) { - return std::make_unique(subProcessIndex); + return std::make_unique(activityRegistry, subProcessIndex); } EventSetupProvider::PreferredProviderInfo preferInfo; @@ -96,7 +96,7 @@ namespace edm { preferPSet.getParameter("@module_label"), false)] = recordToData; } - return std::make_unique(subProcessIndex, &preferInfo); + return std::make_unique(activityRegistry, subProcessIndex, &preferInfo); } // --------------------------------------------------------------- diff --git a/FWCore/Framework/src/EventSetupRecord.cc b/FWCore/Framework/src/EventSetupRecord.cc index 8f45db607fd53..d95133ef5ea2d 100644 --- a/FWCore/Framework/src/EventSetupRecord.cc +++ b/FWCore/Framework/src/EventSetupRecord.cc @@ -17,6 +17,7 @@ // user include files #include "FWCore/Framework/interface/EventSetupRecord.h" +#include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/EventSetupRecordKey.h" #include "FWCore/Framework/interface/DataProxy.h" #include "FWCore/Framework/interface/ComponentDescription.h" @@ -181,7 +182,7 @@ EventSetupRecord::getFromProxy(DataKey const & iKey , if(nullptr!=proxy) { try { convertException::wrap([&]() { - hold = proxy->get(*this, iKey,iTransientAccessOnly); + hold = proxy->get(*this, iKey,iTransientAccessOnly, eventSetup_->activityRegistry()); iDesc = proxy->providerDescription(); }); } @@ -211,7 +212,7 @@ EventSetupRecord::doGet(const DataKey& aKey, bool aGetTransiently) const { if(nullptr != proxy) { try { convertException::wrap([&]() { - proxy->doGet(*this, aKey, aGetTransiently); + proxy->doGet(*this, aKey, aGetTransiently, eventSetup_->activityRegistry()); }); } catch( cms::Exception& e) { diff --git a/FWCore/Framework/src/EventSetupsController.cc b/FWCore/Framework/src/EventSetupsController.cc index e71eb16760f7e..eb9b4574dfebe 100644 --- a/FWCore/Framework/src/EventSetupsController.cc +++ b/FWCore/Framework/src/EventSetupsController.cc @@ -29,12 +29,12 @@ namespace edm { } std::shared_ptr - EventSetupsController::makeProvider(ParameterSet& iPSet) { + EventSetupsController::makeProvider(ParameterSet& iPSet, ActivityRegistry* activityRegistry) { // Makes an EventSetupProvider // Also parses the prefer information from ParameterSets and puts // it in a map that is stored in the EventSetupProvider - std::shared_ptr returnValue(makeEventSetupProvider(iPSet, providers_.size()) ); + std::shared_ptr returnValue(makeEventSetupProvider(iPSet, providers_.size(), activityRegistry) ); // Construct the ESProducers and ESSources // shared_ptrs to them are temporarily stored in this diff --git a/FWCore/Framework/src/EventSetupsController.h b/FWCore/Framework/src/EventSetupsController.h index 75ffe72794ba8..9a03a110d07d4 100644 --- a/FWCore/Framework/src/EventSetupsController.h +++ b/FWCore/Framework/src/EventSetupsController.h @@ -26,6 +26,7 @@ namespace edm { + class ActivityRegistry; class EventSetupRecordIntervalFinder; class ParameterSet; class IOVSyncValue; @@ -74,7 +75,7 @@ namespace edm { public: EventSetupsController(); - std::shared_ptr makeProvider(ParameterSet&); + std::shared_ptr makeProvider(ParameterSet&, ActivityRegistry*); void eventSetupForInstance(IOVSyncValue const& syncValue); diff --git a/FWCore/Framework/src/SubProcess.cc b/FWCore/Framework/src/SubProcess.cc index 2a3bcc29d4fe0..b6d4e86b01124 100644 --- a/FWCore/Framework/src/SubProcess.cc +++ b/FWCore/Framework/src/SubProcess.cc @@ -145,7 +145,7 @@ namespace edm { items.initMisc(*processParameterSet_); // intialize the event setup provider - esp_ = esController.makeProvider(*processParameterSet_); + esp_ = esController.makeProvider(*processParameterSet_, actReg_.get()); branchIDListHelper_ = items.branchIDListHelper(); updateBranchIDListHelper(parentBranchIDListHelper->branchIDLists()); diff --git a/FWCore/Framework/test/dependentrecord_t.cppunit.cc b/FWCore/Framework/test/dependentrecord_t.cppunit.cc index 6a4b8ff6751de..c7ae2bf3435e8 100644 --- a/FWCore/Framework/test/dependentrecord_t.cppunit.cc +++ b/FWCore/Framework/test/dependentrecord_t.cppunit.cc @@ -21,6 +21,7 @@ #include "FWCore/Framework/interface/EventSetupRecordProvider.h" #include "FWCore/Framework/interface/NoRecordException.h" #include "FWCore/Framework/interface/print_eventsetup_record_dependencies.h" +#include "FWCore/ServiceRegistry/interface/ActivityRegistry.h" #include "cppunit/extensions/HelperMacros.h" #include @@ -76,6 +77,9 @@ CPPUNIT_TEST_SUITE_REGISTRATION(testdependentrecord); */ namespace { + +edm::ActivityRegistry activityRegistry; + class DummyProxyProvider : public edm::eventsetup::DataProxyProvider { public: DummyProxyProvider() { @@ -508,7 +512,7 @@ void testdependentrecord::timeAndRunTest() { //check that going all the way through EventSetup works properly - edm::eventsetup::EventSetupProvider provider; + edm::eventsetup::EventSetupProvider provider(&activityRegistry); std::shared_ptr dummyProv = std::make_shared(); provider.add(dummyProv); @@ -556,7 +560,7 @@ void testdependentrecord::timeAndRunTest() { //check that going all the way through EventSetup works properly // using two records with open ended IOVs - edm::eventsetup::EventSetupProvider provider; + edm::eventsetup::EventSetupProvider provider(&activityRegistry); std::shared_ptr dummyProv = std::make_shared(); provider.add(dummyProv); @@ -626,7 +630,7 @@ void testdependentrecord::dependentSetproviderTest() void testdependentrecord::getTest() { - edm::eventsetup::EventSetupProvider provider; + edm::eventsetup::EventSetupProvider provider(&activityRegistry); std::shared_ptr dummyProv = std::make_shared(); provider.add(dummyProv); @@ -652,7 +656,7 @@ void testdependentrecord::getTest() void testdependentrecord::oneOfTwoRecordTest() { - edm::eventsetup::EventSetupProvider provider; + edm::eventsetup::EventSetupProvider provider(&activityRegistry); std::shared_ptr dummyProv = std::make_shared(); provider.add(dummyProv); @@ -682,7 +686,7 @@ void testdependentrecord::oneOfTwoRecordTest() } void testdependentrecord::resetTest() { - edm::eventsetup::EventSetupProvider provider; + edm::eventsetup::EventSetupProvider provider(&activityRegistry); std::shared_ptr dummyProv = std::make_shared(); provider.add(dummyProv); @@ -830,7 +834,7 @@ void testdependentrecord::invalidRecordTest() void testdependentrecord::extendIOVTest() { - edm::eventsetup::EventSetupProvider provider; + edm::eventsetup::EventSetupProvider provider(&activityRegistry); std::shared_ptr dummyProv = std::make_shared(); provider.add(dummyProv); diff --git a/FWCore/Framework/test/esproducer_t.cppunit.cc b/FWCore/Framework/test/esproducer_t.cppunit.cc index 5036dc844d11b..27412e9b39daf 100644 --- a/FWCore/Framework/test/esproducer_t.cppunit.cc +++ b/FWCore/Framework/test/esproducer_t.cppunit.cc @@ -14,6 +14,7 @@ #include "FWCore/Framework/interface/EventSetupProvider.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/ESProducts.h" +#include "FWCore/ServiceRegistry/interface/ActivityRegistry.h" #include "cppunit/extensions/HelperMacros.h" #include "FWCore/Utilities/interface/Exception.h" @@ -22,6 +23,10 @@ using namespace edm::eventsetup; using edm::ESProducer; using edm::EventSetupRecordIntervalFinder; +namespace { +edm::ActivityRegistry activityRegistry; +} + class testEsproducer: public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(testEsproducer); @@ -157,7 +162,7 @@ void testEsproducer::registerTest() void testEsproducer::getFromTest() { - EventSetupProvider provider; + EventSetupProvider provider(&activityRegistry); std::shared_ptr pProxyProv = std::make_shared(); provider.add(pProxyProv); @@ -178,7 +183,7 @@ void testEsproducer::getFromTest() void testEsproducer::getfromShareTest() { - EventSetupProvider provider; + EventSetupProvider provider(&activityRegistry); std::shared_ptr pProxyProv = std::make_shared(); provider.add(pProxyProv); @@ -199,7 +204,7 @@ void testEsproducer::getfromShareTest() void testEsproducer::getfromUniqueTest() { - EventSetupProvider provider; + EventSetupProvider provider(&activityRegistry); std::shared_ptr pProxyProv = std::make_shared(); provider.add(pProxyProv); @@ -221,7 +226,7 @@ void testEsproducer::getfromUniqueTest() void testEsproducer::labelTest() { try { - EventSetupProvider provider; + EventSetupProvider provider(&activityRegistry); std::shared_ptr pProxyProv = std::make_shared(); provider.add(pProxyProv); @@ -284,7 +289,7 @@ class DecoratorProducer : public ESProducer { void testEsproducer::decoratorTest() { - EventSetupProvider provider; + EventSetupProvider provider(&activityRegistry); std::shared_ptr pProxyProv = std::make_shared(); provider.add(pProxyProv); @@ -335,7 +340,7 @@ class DepProducer : public ESProducer { void testEsproducer::dependsOnTest() { - EventSetupProvider provider; + EventSetupProvider provider(&activityRegistry); std::shared_ptr pProxyProv = std::make_shared(); provider.add(pProxyProv); @@ -362,7 +367,7 @@ void testEsproducer::failMultipleRegistration() void testEsproducer::forceCacheClearTest() { - EventSetupProvider provider; + EventSetupProvider provider(&activityRegistry); std::shared_ptr pProxyProv = std::make_shared(); provider.add(pProxyProv); diff --git a/FWCore/Framework/test/eventsetup_t.cppunit.cc b/FWCore/Framework/test/eventsetup_t.cppunit.cc index 8c50a28a1eadf..ed732ddd52119 100644 --- a/FWCore/Framework/test/eventsetup_t.cppunit.cc +++ b/FWCore/Framework/test/eventsetup_t.cppunit.cc @@ -34,6 +34,7 @@ #include "FWCore/Framework/interface/DataProxyProvider.h" #include "FWCore/Framework/interface/EventSetupRecordProviderFactoryTemplate.h" #include "FWCore/Framework/test/DummyEventSetupRecordRetriever.h" +#include "FWCore/ServiceRegistry/interface/ActivityRegistry.h" using namespace edm; namespace { @@ -100,10 +101,13 @@ CPPUNIT_TEST_SUITE_END(); ///registration of the test so that the runner can find it CPPUNIT_TEST_SUITE_REGISTRATION(testEventsetup); +namespace { + edm::ActivityRegistry activityRegistry; +} void testEventsetup::constructTest() { - eventsetup::EventSetupProvider provider; + eventsetup::EventSetupProvider provider(&activityRegistry); const Timestamp time(1); const IOVSyncValue timestamp(time); EventSetup const& eventSetup = provider.eventSetupForInstance(timestamp); @@ -112,7 +116,7 @@ void testEventsetup::constructTest() void testEventsetup::getTest() { - eventsetup::EventSetupProvider provider; + eventsetup::EventSetupProvider provider(&activityRegistry); EventSetup const& eventSetup = provider.eventSetupForInstance(IOVSyncValue::invalidIOVSyncValue()); CPPUNIT_ASSERT(non_null(&eventSetup)); //eventSetup.get(); @@ -127,7 +131,7 @@ void testEventsetup::getTest() void testEventsetup::tryToGetTest() { - eventsetup::EventSetupProvider provider; + eventsetup::EventSetupProvider provider(&activityRegistry); EventSetup const& eventSetup = provider.eventSetupForInstance(IOVSyncValue::invalidIOVSyncValue()); CPPUNIT_ASSERT(non_null(&eventSetup)); //eventSetup.get(); @@ -142,7 +146,7 @@ void testEventsetup::tryToGetTest() void testEventsetup::getExcTest() { - eventsetup::EventSetupProvider provider; + eventsetup::EventSetupProvider provider(&activityRegistry); EventSetup const& eventSetup = provider.eventSetupForInstance(IOVSyncValue::invalidIOVSyncValue()); CPPUNIT_ASSERT(non_null(&eventSetup)); eventSetup.get(); @@ -152,6 +156,9 @@ void testEventsetup::getExcTest() class DummyEventSetupProvider : public edm::eventsetup::EventSetupProvider { public: + + DummyEventSetupProvider(ActivityRegistry* activityRegistry) : EventSetupProvider(activityRegistry) { } + template void insert(std::unique_ptr iRecord) { edm::eventsetup::EventSetupProvider::insert(std::move(iRecord)); @@ -160,7 +167,7 @@ class DummyEventSetupProvider : public edm::eventsetup::EventSetupProvider { void testEventsetup::recordProviderTest() { - DummyEventSetupProvider provider; + DummyEventSetupProvider provider(&activityRegistry); typedef eventsetup::EventSetupRecordProviderTemplate DummyRecordProvider; auto dummyRecordProvider = std::make_unique(); @@ -203,7 +210,7 @@ class DummyFinder : public EventSetupRecordIntervalFinder { void testEventsetup::recordValidityTest() { - DummyEventSetupProvider provider; + DummyEventSetupProvider provider(&activityRegistry); typedef eventsetup::EventSetupRecordProviderTemplate DummyRecordProvider; auto dummyRecordProvider = std::make_unique(); @@ -240,7 +247,7 @@ void testEventsetup::recordValidityTest() void testEventsetup::recordValidityExcTest() { - DummyEventSetupProvider provider; + DummyEventSetupProvider provider(&activityRegistry); typedef eventsetup::EventSetupRecordProviderTemplate DummyRecordProvider; auto dummyRecordProvider = std::make_unique(); @@ -277,7 +284,7 @@ static eventsetup::EventSetupRecordProviderFactoryTemplate s_factor void testEventsetup::proxyProviderTest() { - eventsetup::EventSetupProvider provider; + eventsetup::EventSetupProvider provider(&activityRegistry); std::shared_ptr dummyProv = std::make_shared(); provider.add(dummyProv); @@ -290,7 +297,7 @@ void testEventsetup::producerConflictTest() { edm::eventsetup::ComponentDescription description("DummyProxyProvider","",false); using edm::eventsetup::test::DummyProxyProvider; - eventsetup::EventSetupProvider provider; + eventsetup::EventSetupProvider provider(&activityRegistry); { std::shared_ptr dummyProv = std::make_shared(); dummyProv->setDescription(description); @@ -309,7 +316,7 @@ void testEventsetup::sourceConflictTest() { edm::eventsetup::ComponentDescription description("DummyProxyProvider","",true); using edm::eventsetup::test::DummyProxyProvider; - eventsetup::EventSetupProvider provider; + eventsetup::EventSetupProvider provider(&activityRegistry); { std::shared_ptr dummyProv = std::make_shared(); dummyProv->setDescription(description); @@ -330,7 +337,7 @@ void testEventsetup::twoSourceTest() { edm::eventsetup::ComponentDescription description("DummyProxyProvider","",true); using edm::eventsetup::test::DummyProxyProvider; - eventsetup::EventSetupProvider provider; + eventsetup::EventSetupProvider provider(&activityRegistry); { std::shared_ptr dummyProv = std::make_shared(); dummyProv->setDescription(description); @@ -356,7 +363,7 @@ void testEventsetup::provenanceTest() DummyData kGood; kGood.value_ = 1; DummyData kBad; kBad.value_=0; - eventsetup::EventSetupProvider provider; + eventsetup::EventSetupProvider provider(&activityRegistry); try { { edm::eventsetup::ComponentDescription description("DummyProxyProvider","",true); @@ -397,7 +404,7 @@ void testEventsetup::getDataWithLabelTest() DummyData kGood; kGood.value_ = 1; DummyData kBad; kBad.value_=0; - eventsetup::EventSetupProvider provider; + eventsetup::EventSetupProvider provider(&activityRegistry); try { { edm::eventsetup::ComponentDescription description("DummyProxyProvider","",true); @@ -440,7 +447,7 @@ void testEventsetup::getDataWithESInputTagTest() DummyData kGood; kGood.value_ = 1; DummyData kBad; kBad.value_=0; - eventsetup::EventSetupProvider provider; + eventsetup::EventSetupProvider provider(&activityRegistry); try { { edm::eventsetup::ComponentDescription description("DummyProxyProvider","testOne",true); @@ -515,7 +522,7 @@ void testEventsetup::sourceProducerResolutionTest() DummyData kBad; kBad.value_=0; { - eventsetup::EventSetupProvider provider; + eventsetup::EventSetupProvider provider(&activityRegistry); { edm::eventsetup::ComponentDescription description("DummyProxyProvider","",true); std::shared_ptr dummyProv = std::make_shared(kBad); @@ -541,7 +548,7 @@ void testEventsetup::sourceProducerResolutionTest() //reverse order { - eventsetup::EventSetupProvider provider; + eventsetup::EventSetupProvider provider(&activityRegistry); { edm::eventsetup::ComponentDescription description("DummyProxyProvider","",false); std::shared_ptr dummyProv = std::make_shared(kGood); @@ -583,7 +590,7 @@ void testEventsetup::preferTest() //default means use all proxies preferInfo[ComponentDescription("DummyProxyProvider","",false)]=recordToData; - eventsetup::EventSetupProvider provider(0U, &preferInfo); + eventsetup::EventSetupProvider provider(&activityRegistry, 0U, &preferInfo); { edm::eventsetup::ComponentDescription description("DummyProxyProvider","bad",false); std::shared_ptr dummyProv = std::make_shared(kBad); @@ -614,7 +621,7 @@ void testEventsetup::preferTest() EventSetupProvider::RecordToDataMap recordToData; //default means use all proxies preferInfo[ComponentDescription("DummyProxyProvider","",false)]=recordToData; - eventsetup::EventSetupProvider provider(0U, &preferInfo); + eventsetup::EventSetupProvider provider(&activityRegistry, 0U, &preferInfo); { edm::eventsetup::ComponentDescription description("DummyProxyProvider","",true); std::shared_ptr dummyProv = std::make_shared(kGood); @@ -646,7 +653,7 @@ void testEventsetup::preferTest() recordToData.insert(std::make_pair(std::string("DummyRecord"), std::make_pair(std::string("DummyData"),std::string()))); preferInfo[ComponentDescription("DummyProxyProvider","",false)]=recordToData; - eventsetup::EventSetupProvider provider(0U, &preferInfo); + eventsetup::EventSetupProvider provider(&activityRegistry, 0U, &preferInfo); { edm::eventsetup::ComponentDescription description("DummyProxyProvider","",true); std::shared_ptr dummyProv = std::make_shared(kGood); @@ -683,7 +690,7 @@ void testEventsetup::introspectionTest() DummyData kGood; kGood.value_ = 1; DummyData kBad; kBad.value_=0; - eventsetup::EventSetupProvider provider; + eventsetup::EventSetupProvider provider(&activityRegistry); try { { edm::eventsetup::ComponentDescription description("DummyProxyProvider","",true); @@ -721,7 +728,7 @@ void testEventsetup::introspectionTest() void testEventsetup::iovExtentionTest() { - DummyEventSetupProvider provider; + DummyEventSetupProvider provider(&activityRegistry); typedef eventsetup::EventSetupRecordProviderTemplate DummyRecordProvider; auto dummyRecordProvider = std::make_unique(); diff --git a/FWCore/Framework/test/eventsetupplugin_t.cppunit.cc b/FWCore/Framework/test/eventsetupplugin_t.cppunit.cc index c5ff6aa00d5ce..0fccc81721b86 100644 --- a/FWCore/Framework/test/eventsetupplugin_t.cppunit.cc +++ b/FWCore/Framework/test/eventsetupplugin_t.cppunit.cc @@ -22,9 +22,14 @@ #include "FWCore/Framework/interface/ModuleFactory.h" #include "FWCore/Framework/interface/EventSetupProvider.h" #include "FWCore/Framework/src/EventSetupsController.h" +#include "FWCore/ServiceRegistry/interface/ActivityRegistry.h" using namespace edm::eventsetup; +namespace { + edm::ActivityRegistry activityRegistry; +} + class testEventsetupplugin: public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(testEventsetupplugin); @@ -57,7 +62,7 @@ void testEventsetupplugin::finderTest() { doInit(); EventSetupsController esController; - EventSetupProvider provider; + EventSetupProvider provider(&activityRegistry); edm::ParameterSet dummyFinderPSet; dummyFinderPSet.addParameter("@module_type", std::string("LoadableDummyFinder")); diff --git a/FWCore/Framework/test/eventsetuprecord_t.cppunit.cc b/FWCore/Framework/test/eventsetuprecord_t.cppunit.cc index 40f2a20f11318..cf5509cd3c005 100644 --- a/FWCore/Framework/test/eventsetuprecord_t.cppunit.cc +++ b/FWCore/Framework/test/eventsetuprecord_t.cppunit.cc @@ -8,6 +8,7 @@ #include "cppunit/extensions/HelperMacros.h" +#include "FWCore/Framework/interface/EventSetupProvider.h" #include "FWCore/Framework/interface/EventSetupRecordImplementation.h" #include "FWCore/Framework/interface/EventSetupRecordProviderTemplate.h" #include "FWCore/Framework/interface/EventSetupRecordProviderFactoryManager.h" @@ -23,6 +24,12 @@ #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/ESTransientHandle.h" +#include "FWCore/ServiceRegistry/interface/ActivityRegistry.h" + +namespace { + edm::ActivityRegistry activityRegistry; +} + using namespace edm; using namespace edm::eventsetup; namespace eventsetuprecord_t { @@ -190,7 +197,10 @@ void testEventsetupRecord::proxyTest() void testEventsetupRecord::getTest() { + eventsetup::EventSetupProvider provider(&activityRegistry); DummyRecord dummyRecord; + provider.addRecordToEventSetup(dummyRecord); + FailingDummyProxy dummyProxy; const DataKey dummyDataKey(DataKey::makeTypeTag(), @@ -269,7 +279,9 @@ void testEventsetupRecord::getNodataExpTest() void testEventsetupRecord::getExepTest() { + eventsetup::EventSetupProvider provider(&activityRegistry); DummyRecord dummyRecord; + provider.addRecordToEventSetup(dummyRecord); FailingDummyProxy dummyProxy; const DataKey dummyDataKey(DataKey::makeTypeTag(),""); @@ -284,7 +296,10 @@ void testEventsetupRecord::getExepTest() void testEventsetupRecord::doGetTest() { + eventsetup::EventSetupProvider provider(&activityRegistry); DummyRecord dummyRecord; + provider.addRecordToEventSetup(dummyRecord); + FailingDummyProxy dummyProxy; const DataKey dummyDataKey(DataKey::makeTypeTag(), @@ -432,7 +447,9 @@ void testEventsetupRecord::introspectionTest() void testEventsetupRecord::doGetExepTest() { + eventsetup::EventSetupProvider provider(&activityRegistry); DummyRecord dummyRecord; + provider.addRecordToEventSetup(dummyRecord); FailingDummyProxy dummyProxy; const DataKey dummyDataKey(DataKey::makeTypeTag(), @@ -459,7 +476,10 @@ void testEventsetupRecord::proxyResetTest() CPPUNIT_ASSERT(0 !=prov); if(prov == 0) return; // To silence Coverity const EventSetupRecordProviderTemplate* constProv = prov; - + + eventsetup::EventSetupProvider provider(&activityRegistry); + prov->addRecordTo(provider); + const EventSetupRecord& dummyRecord = constProv->record(); unsigned long long cacheID = dummyRecord.cacheIdentifier(); @@ -508,7 +528,10 @@ void testEventsetupRecord::transientTest() EventSetupRecordProviderTemplate* prov= dynamic_cast*>(&(*dummyProvider)); CPPUNIT_ASSERT(0 !=prov); - if(prov == 0) return; // To silence Coverity + if(prov == 0) return; // To silence Coverity + + eventsetup::EventSetupProvider provider(&activityRegistry); + prov->addRecordTo(provider); const EventSetupRecordProviderTemplate* constProv = prov; const EventSetupRecord& dummyRecord = constProv->record(); diff --git a/FWCore/Framework/test/eventsetupscontroller_t.cppunit.cc b/FWCore/Framework/test/eventsetupscontroller_t.cppunit.cc index 809a5c57f5fc0..a6ee8471ab79b 100644 --- a/FWCore/Framework/test/eventsetupscontroller_t.cppunit.cc +++ b/FWCore/Framework/test/eventsetupscontroller_t.cppunit.cc @@ -10,12 +10,17 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/test/DummyFinder.h" #include "FWCore/Framework/test/DummyProxyProvider.h" +#include "FWCore/ServiceRegistry/interface/ActivityRegistry.h" #include "FWCore/Utilities/interface/Exception.h" #include #include #include +namespace { +edm::ActivityRegistry activityRegistry; +} + class TestEventSetupsController: public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(TestEventSetupsController); @@ -52,9 +57,9 @@ void TestEventSetupsController::constructorTest() { pset.addParameter >("@all_essources", emptyVStrings); pset.addParameter >("@all_esmodules", emptyVStrings); - esController.makeProvider(pset); - esController.makeProvider(pset); - esController.makeProvider(pset); + esController.makeProvider(pset, &activityRegistry); + esController.makeProvider(pset, &activityRegistry); + esController.makeProvider(pset, &activityRegistry); CPPUNIT_ASSERT(esController.providers().size() == 3); CPPUNIT_ASSERT(esController.providers()[0]->subProcessIndex() == 0); diff --git a/FWCore/Framework/test/fullchain_t.cppunit.cc b/FWCore/Framework/test/fullchain_t.cppunit.cc index 08a1affe554d8..9bf32c68c4488 100644 --- a/FWCore/Framework/test/fullchain_t.cppunit.cc +++ b/FWCore/Framework/test/fullchain_t.cppunit.cc @@ -16,12 +16,17 @@ #include "FWCore/Framework/test/DummyData.h" #include "FWCore/Framework/test/DummyFinder.h" #include "FWCore/Framework/test/DummyProxyProvider.h" +#include "FWCore/ServiceRegistry/interface/ActivityRegistry.h" #include "cppunit/extensions/HelperMacros.h" using namespace edm; using namespace edm::eventsetup; using namespace edm::eventsetup::test; +namespace { +edm::ActivityRegistry activityRegistry; +} + class testfullChain: public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(testfullChain); @@ -41,7 +46,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION(testfullChain); void testfullChain::getfromDataproxyproviderTest() { - eventsetup::EventSetupProvider provider; + eventsetup::EventSetupProvider provider(&activityRegistry); std::shared_ptr pProxyProv = std::make_shared(); provider.add(pProxyProv); diff --git a/FWCore/Integration/test/testSubProcess_cfg.py b/FWCore/Integration/test/testSubProcess_cfg.py index 17fda09125641..4800d41d5f2f2 100644 --- a/FWCore/Integration/test/testSubProcess_cfg.py +++ b/FWCore/Integration/test/testSubProcess_cfg.py @@ -1,7 +1,9 @@ import FWCore.ParameterSet.Config as cms process = cms.Process("FIRST") -process.Tracer = cms.Service('Tracer') +process.Tracer = cms.Service('Tracer', + dumpEventSetupInfo = cms.untracked.bool(True) +) process.load("FWCore.MessageLogger.MessageLogger_cfi") diff --git a/FWCore/Integration/test/unit_test_outputs/testSubProcess.grep.txt b/FWCore/Integration/test/unit_test_outputs/testSubProcess.grep.txt index d7aa064f592e8..50abd370880da 100644 --- a/FWCore/Integration/test/unit_test_outputs/testSubProcess.grep.txt +++ b/FWCore/Integration/test/unit_test_outputs/testSubProcess.grep.txt @@ -1,6 +1,12 @@ Sharing ESSource: class=DoodadESSource label='' Sharing ESSource: class=DoodadESSource label='' Sharing ESSource: class=DoodadESSource label='' +preLockEventSetupGet GadgetRcd edmtest::Doodad abcd +postLockEventSetupGet GadgetRcd edmtest::Doodad abcd +postEventSetupGet GadgetRcd edmtest::Doodad abcd got data of type "edmtest::Doodad" with name "abcd" in record GadgetRcd +preLockEventSetupGet GadgetRcd edmtest::Doodad abc +postLockEventSetupGet GadgetRcd edmtest::Doodad abc +postEventSetupGet GadgetRcd edmtest::Doodad abc got data of type "edmtest::Doodad" with name "abc" in record GadgetRcd got data of type "edmtest::Doodad" with name "abc" in record GadgetRcd diff --git a/FWCore/ServiceRegistry/interface/ActivityRegistry.h b/FWCore/ServiceRegistry/interface/ActivityRegistry.h index 486c04718f687..99de928d158a0 100644 --- a/FWCore/ServiceRegistry/interface/ActivityRegistry.h +++ b/FWCore/ServiceRegistry/interface/ActivityRegistry.h @@ -22,6 +22,28 @@ unscheduled execution. The tests are in FWCore/Integration/test: run_TestGetBy.sh testGetBy1_cfg.py testGetBy2_cfg.py + +There are four little details you should remember when adding new signals +to this file that go beyond the obvious cut and paste type of edits. + 1. The number at the end of the AR_WATCH_USING_METHOD_X macro definition + is the number of function arguments. It will not compile if you use the + wrong number there. + 2. Use connect or connect_front depending on whether the callback function + should be called for different services in the order the Services were + constructed or in reverse order. Begin signals are usually forward and + End signals in reverse, but if the service does not depend on other services + and vice versa this does not matter. + 3. The signal needs to be added to either connectGlobals or connectLocals + in the ActivityRegistry.cc file, depending on whether a signal is seen + by children or parents when there are SubProcesses. For example, source + signals are only generated in the top level process and should be seen + by all child SubProcesses so they are in connectGlobals. Most signals + however belong in connectLocals. It does not really matter in jobs + without at least one SubProcess. + 4. Each signal also needs to be added in copySlotsFrom in + ActivityRegistry.cc. Whether it uses copySlotsToFrom or + copySlotsToFromReverse depends on the same ordering issue as the connect + or connect_front choice in item 2 above. */ // // Original Author: Chris Jones @@ -60,6 +82,11 @@ namespace edm { class ProcessContext; class ModuleCallingContext; class PathsAndConsumesOfModulesBase; + namespace eventsetup { + struct ComponentDescription; + class DataKey; + class EventSetupRecordKey; + } namespace service { class SystemBounds; } @@ -972,6 +999,30 @@ namespace edm { // WARNING - ModuleDescription is not in fixed place. See note M above. AR_WATCH_USING_METHOD_1(watchPostSourceConstruction) + typedef signalslot::Signal PreLockEventSetupGet; + ///signal is emitted before lock taken in EventSetup DataProxy::get function + PreLockEventSetupGet preLockEventSetupGetSignal_; + void watchPreLockEventSetupGet(PreLockEventSetupGet::slot_type const& iSlot) { + preLockEventSetupGetSignal_.connect(iSlot); + } + AR_WATCH_USING_METHOD_3(watchPreLockEventSetupGet) + + typedef signalslot::Signal PostLockEventSetupGet; + ///signal is emitted after lock taken in EventSetup DataProxy::get function + PostLockEventSetupGet postLockEventSetupGetSignal_; + void watchPostLockEventSetupGet(PostLockEventSetupGet::slot_type const& iSlot) { + postLockEventSetupGetSignal_.connect_front(iSlot); + } + AR_WATCH_USING_METHOD_3(watchPostLockEventSetupGet) + + typedef signalslot::Signal PostEventSetupGet; + ///signal is emitted after getImpl has returned in the EventSetup DataProxy::get function + PostEventSetupGet postEventSetupGetSignal_; + void watchPostEventSetupGet(PostEventSetupGet::slot_type const& iSlot) { + postEventSetupGetSignal_.connect_front(iSlot); + } + AR_WATCH_USING_METHOD_3(watchPostEventSetupGet) + // ---------- member functions --------------------------- ///forwards our signals to slots connected to iOther diff --git a/FWCore/ServiceRegistry/src/ActivityRegistry.cc b/FWCore/ServiceRegistry/src/ActivityRegistry.cc index a990a76c4689c..192c021d64e0f 100644 --- a/FWCore/ServiceRegistry/src/ActivityRegistry.cc +++ b/FWCore/ServiceRegistry/src/ActivityRegistry.cc @@ -258,6 +258,10 @@ namespace edm { //preModuleEndLumiSignal_.connect(std::cref(iOther.preModuleEndLumiSignal_)); //postModuleEndLumiSignal_.connect(std::cref(iOther.postModuleEndLumiSignal_)); + + preLockEventSetupGetSignal_.connect(std::cref(iOther.preLockEventSetupGetSignal_)); + postLockEventSetupGetSignal_.connect(std::cref(iOther.postLockEventSetupGetSignal_)); + postEventSetupGetSignal_.connect(std::cref(iOther.postEventSetupGetSignal_)); } void @@ -435,6 +439,9 @@ namespace edm { copySlotsToFrom(preSourceConstructionSignal_, iOther.preSourceConstructionSignal_); copySlotsToFromReverse(postSourceConstructionSignal_, iOther.postSourceConstructionSignal_); + copySlotsToFrom(preLockEventSetupGetSignal_, iOther.preLockEventSetupGetSignal_); + copySlotsToFromReverse(postLockEventSetupGetSignal_, iOther.postLockEventSetupGetSignal_); + copySlotsToFromReverse(postEventSetupGetSignal_, iOther.postEventSetupGetSignal_); } // diff --git a/FWCore/Services/plugins/Timing.cc b/FWCore/Services/plugins/Timing.cc index 56379c987bcc5..1c76e73403599 100644 --- a/FWCore/Services/plugins/Timing.cc +++ b/FWCore/Services/plugins/Timing.cc @@ -29,9 +29,16 @@ #include #include #include +#include namespace edm { - + + namespace eventsetup { + struct ComponentDescription; + class DataKey; + class EventSetupRecordKey; + } + namespace service { class Timing : public TimingServiceBase { public: @@ -76,6 +83,28 @@ namespace edm { double postCommon() const; + void preLockEventSetupGet(eventsetup::ComponentDescription const*, + eventsetup::EventSetupRecordKey const&, + eventsetup::DataKey const&); + + void postLockEventSetupGet(eventsetup::ComponentDescription const*, + eventsetup::EventSetupRecordKey const&, + eventsetup::DataKey const&); + + void postEventSetupGet(eventsetup::ComponentDescription const*, + eventsetup::EventSetupRecordKey const&, + eventsetup::DataKey const&); + + struct CountAndTime { + public: + CountAndTime(unsigned int count, double time) : count_(count), time_(time) { } + unsigned int count_; + double time_; + }; + + void accumulateTimeBegin(std::atomic& countAndTime, double& accumulatedTime); + void accumulateTimeEnd(std::atomic& countAndTime, double& accumulatedTime); + double curr_job_time_; // seconds double curr_job_cpu_; // seconds std::atomic extra_job_cpu_; //seconds @@ -95,6 +124,14 @@ namespace edm { std::atomic total_event_count_; unsigned int nStreams_; unsigned int nThreads_; + + CountAndTime countAndTimeZero_; + + std::atomic countAndTimeForLock_; + double accumulatedTimeForLock_; + + std::atomic countAndTimeForGet_; + double accumulatedTimeForGet_; }; } } @@ -177,13 +214,23 @@ namespace edm { threshold_(iPS.getUntrackedParameter("excessiveTimeThreshold")), max_events_time_(), min_events_time_(), - total_event_count_(0) { + total_event_count_(0), + countAndTimeZero_{0, 0.0}, + countAndTimeForLock_{&countAndTimeZero_}, + accumulatedTimeForLock_{0.0}, + countAndTimeForGet_{&countAndTimeZero_}, + accumulatedTimeForGet_{0.0} { + iRegistry.watchPostBeginJob(this, &Timing::postBeginJob); iRegistry.watchPostEndJob(this, &Timing::postEndJob); iRegistry.watchPreEvent(this, &Timing::preEvent); iRegistry.watchPostEvent(this, &Timing::postEvent); + iRegistry.watchPreLockEventSetupGet(this, &Timing::preLockEventSetupGet); + iRegistry.watchPostLockEventSetupGet(this, &Timing::postLockEventSetupGet); + iRegistry.watchPostEventSetupGet(this, &Timing::postEventSetupGet); + bool checkThreshold = true; if (threshold_ <= 0.0) { //we need to ignore the threshold check @@ -354,6 +401,8 @@ namespace edm { << " - Total loop: " << total_loop_time <<"\n" << " - Total init: " << total_initialization_time <<"\n" << " - Total job: " << total_job_time << "\n" + << " - EventSetup Lock: " << accumulatedTimeForLock_ << "\n" + << " - EventSetup Get: " << accumulatedTimeForGet_ << "\n" << " Event Throughput: "<< event_throughput <<" ev/s\n" << " CPU Summary: \n" << " - Total loop: " << total_loop_cpu << "\n" @@ -378,6 +427,8 @@ namespace edm { reportData.insert(std::make_pair("TotalInitCPU", d2str(total_initialization_cpu))); reportData.insert(std::make_pair("NumberOfStreams",ui2str(nStreams_))); reportData.insert(std::make_pair("NumberOfThreads",ui2str(nThreads_))); + reportData.insert(std::make_pair("EventSetup Lock",d2str(accumulatedTimeForLock_))); + reportData.insert(std::make_pair("EventSetup Get",d2str(accumulatedTimeForGet_))); reportSvc->reportPerformanceSummary("Timing", reportData); } } @@ -493,6 +544,80 @@ namespace edm { } return t; } + + void + Timing::preLockEventSetupGet(eventsetup::ComponentDescription const*, + eventsetup::EventSetupRecordKey const&, + eventsetup::DataKey const&) { + + accumulateTimeBegin(countAndTimeForLock_, accumulatedTimeForLock_); + } + + void + Timing::postLockEventSetupGet(eventsetup::ComponentDescription const*, + eventsetup::EventSetupRecordKey const&, + eventsetup::DataKey const&) { + + accumulateTimeEnd(countAndTimeForLock_, accumulatedTimeForLock_); + accumulateTimeBegin(countAndTimeForGet_, accumulatedTimeForGet_); + } + + void + Timing::postEventSetupGet(eventsetup::ComponentDescription const*, + eventsetup::EventSetupRecordKey const&, + eventsetup::DataKey const&) { + + accumulateTimeEnd(countAndTimeForGet_, accumulatedTimeForGet_); + } + + void + Timing::accumulateTimeBegin(std::atomic& countAndTime, double& accumulatedTime) { + + double newTime = getTime(); + auto newStat = std::make_unique(0, newTime); + + CountAndTime* oldStat = countAndTime.load(); + while (oldStat == nullptr || + !countAndTime.compare_exchange_strong(oldStat, nullptr)) { + oldStat = countAndTime.load(); + } + + newStat->count_ = oldStat->count_ + 1; + if (oldStat->count_ != 0) { + accumulatedTime += (newTime - oldStat->time_) * oldStat->count_; + } + countAndTime.store(newStat.release()); + if (oldStat != &countAndTimeZero_) { + delete oldStat; + } + } + + void + Timing::accumulateTimeEnd(std::atomic& countAndTime, double& accumulatedTime) { + + double newTime = getTime(); + + CountAndTime* oldStat = countAndTime.load(); + while (oldStat == nullptr || + !countAndTime.compare_exchange_strong(oldStat, nullptr)) { + oldStat = countAndTime.load(); + } + + if (oldStat->count_ == 1) { + accumulatedTime += newTime - oldStat->time_; + countAndTime.store(&countAndTimeZero_); + } else { + try { + auto newStat = std::make_unique(oldStat->count_ - 1, newTime); + accumulatedTime += (newTime - oldStat->time_) * oldStat->count_; + countAndTime.store(newStat.release()); + } catch (std::exception &) { + countAndTime.store(oldStat); + throw; + } + } + delete oldStat; + } } } diff --git a/FWCore/Services/plugins/Tracer.cc b/FWCore/Services/plugins/Tracer.cc index 155cc199dbad1..2ad1bcad227a8 100644 --- a/FWCore/Services/plugins/Tracer.cc +++ b/FWCore/Services/plugins/Tracer.cc @@ -9,6 +9,11 @@ // Original Author: Chris Jones // Created: Thu Sep 8 14:17:58 EDT 2005 // + +#include "FWCore/Framework/interface/ComponentDescription.h" +#include "FWCore/Framework/interface/DataKey.h" +#include "FWCore/Framework/interface/EventSetupRecordKey.h" + #include "FWCore/ServiceRegistry/interface/ServiceMaker.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -163,13 +168,26 @@ namespace edm { void preSourceConstruction(ModuleDescription const& md); void postSourceConstruction(ModuleDescription const& md); - + + void preLockEventSetupGet(eventsetup::ComponentDescription const*, + eventsetup::EventSetupRecordKey const&, + eventsetup::DataKey const&); + + void postLockEventSetupGet(eventsetup::ComponentDescription const*, + eventsetup::EventSetupRecordKey const&, + eventsetup::DataKey const&); + + void postEventSetupGet(eventsetup::ComponentDescription const*, + eventsetup::EventSetupRecordKey const&, + eventsetup::DataKey const&); + private: std::string indention_; std::set dumpContextForLabels_; bool dumpNonModuleContext_; bool dumpPathsAndConsumes_; bool printTimestamps_; + bool dumpEventSetupInfo_; }; } } @@ -202,7 +220,8 @@ Tracer::Tracer(ParameterSet const& iPS, ActivityRegistry&iRegistry) : dumpContextForLabels_(), dumpNonModuleContext_(iPS.getUntrackedParameter("dumpNonModuleContext")), dumpPathsAndConsumes_(iPS.getUntrackedParameter("dumpPathsAndConsumes")), - printTimestamps_(iPS.getUntrackedParameter("printTimestamps")) + printTimestamps_(iPS.getUntrackedParameter("printTimestamps")), + dumpEventSetupInfo_(iPS.getUntrackedParameter("dumpEventSetupInfo")) { for (std::string & label: iPS.getUntrackedParameter>("dumpContextForLabels")) dumpContextForLabels_.insert(std::move(label)); @@ -306,7 +325,13 @@ Tracer::Tracer(ParameterSet const& iPS, ActivityRegistry&iRegistry) : iRegistry.watchPreSourceConstruction(this, &Tracer::preSourceConstruction); iRegistry.watchPostSourceConstruction(this, &Tracer::postSourceConstruction); - + + if (dumpEventSetupInfo_) { + iRegistry.watchPreLockEventSetupGet(this, &Tracer::preLockEventSetupGet); + iRegistry.watchPostLockEventSetupGet(this, &Tracer::postLockEventSetupGet); + iRegistry.watchPostEventSetupGet(this, &Tracer::postEventSetupGet); + } + iRegistry.preSourceEarlyTerminationSignal_.connect([this](edm::TerminationOrigin iOrigin) { LogAbsolute out("Tracer"); out << TimeStamper(printTimestamps_); @@ -356,6 +381,7 @@ Tracer::fillDescriptions(edm::ConfigurationDescriptions & descriptions) { desc.addUntracked("dumpNonModuleContext", false)->setComment("Prints context information to cout for the transitions not associated with any module label"); desc.addUntracked("dumpPathsAndConsumes", false)->setComment("Prints information to cout about paths, endpaths, products consumed by modules and the dependencies between modules created by the products they consume"); desc.addUntracked("printTimestamps", false)->setComment("Prints a time stamp for every transition"); + desc.addUntracked("dumpEventSetupInfo", false)->setComment("Prints info 3 times when an event setup cache is filled, before the lock, after the lock, and after filling"); descriptions.add("Tracer", desc); descriptions.setComment("This service prints each phase the framework is processing, e.g. constructing a module,running a module, etc."); } @@ -1255,7 +1281,41 @@ Tracer::postSourceConstruction(ModuleDescription const& desc) { } } -using edm::service::Tracer; -DEFINE_FWK_SERVICE(Tracer); +void +Tracer::preLockEventSetupGet(eventsetup::ComponentDescription const* desc, + eventsetup::EventSetupRecordKey const& recordKey, + eventsetup::DataKey const& dataKey) { + LogAbsolute out("Tracer"); + out << "preLockEventSetupGet "; + out << desc->label_ << " "; + out << recordKey.name() << " "; + out << dataKey.type().name() << " "; + out << dataKey.name().value(); +} + +void +Tracer::postLockEventSetupGet(eventsetup::ComponentDescription const* desc, + eventsetup::EventSetupRecordKey const& recordKey, + eventsetup::DataKey const& dataKey) { + LogAbsolute out("Tracer"); + out << "postLockEventSetupGet "; + out << desc->label_ << " "; + out << recordKey.name() << " "; + out << dataKey.type().name() << " "; + out << dataKey.name().value(); +} +void +Tracer::postEventSetupGet(eventsetup::ComponentDescription const* desc, + eventsetup::EventSetupRecordKey const& recordKey, + eventsetup::DataKey const& dataKey) { + LogAbsolute out("Tracer"); + out << "postEventSetupGet "; + out << desc->label_ << " "; + out << recordKey.name() << " "; + out << dataKey.type().name() << " "; + out << dataKey.name().value(); +} +using edm::service::Tracer; +DEFINE_FWK_SERVICE(Tracer);